pathom

sheluchin 2024-02-16T18:40:02.820689Z

Is there any way to automatically create resolvers from an OpenAPI schema?

wilkerlucio 2024-02-16T18:55:10.113169Z

maybe its possible, I never tried for real

sheluchin 2024-02-16T18:56:30.774539Z

OAI schemas and Pathom seem like a good match. I'm surprised there isn't really any discussion on the subject here. In theory, the mapping of an OAI endpoint to a resolver should be straight forward.

wilkerlucio 2024-02-16T19:00:02.167799Z

depends on how good their schema can capture things, I looked at it once, and one thing that might be tricky is to figure the semantic mapping for the input arguments for the endpoints

wilkerlucio 2024-02-16T19:01:06.430969Z

I remember seeing things where the input is declared as a name with a type, how you name them (whats the namespace?)? how you relate them to outputs from other endpoints?

wilkerlucio 2024-02-16T19:01:32.459709Z

this I think is the tricky part, I think there might be a solution (even if its not fully automatic). its an interesting thing to explore for sure 🙂

sheluchin 2024-02-16T19:10:28.008599Z

> whats the namespace? This part is tricky since there are no namespaces in JSON, but maybe namespacing in this case can just be ignored or use a constant namespace similar to ::p.gql/namespace "swapi"? > how you relate them to outputs from other endpoints? This can obviously differ depending on the quality of the spec, but presuming its perfect, we should be able to refer to the top-level definitions key in the spec. Like the canonical https://petstore.swagger.io/v2/swagger.json includes a definition for Pet and then refers to it using a ref like "#/definitions/Pet" where that type is returned. Somewhere along the way it might require manually creating a renames-map or something of the sort.