graphql-mesh icon indicating copy to clipboard operation
graphql-mesh copied to clipboard

Postman-Handler/Loader: Postman-Collections as source

Open soerenuhrbach opened this issue 6 months ago • 5 comments

Is your feature request related to a problem? Please describe.

Its possible to define api's in postman and document them there. I would like to use this documentation, that can exported as json, as a source to use with graphql-mesh.

Describe the solution you'd like

I think it would be great to define a postman source. An example configuration could look like:

sources:
  - name: SomeApiFromPostman
    handler:
      postman:
        source: <url-or-link-to-postman-collection-export>
        variables:
          SomeVariable: SomeValue

Describe alternatives you've considered

Anyway external tool could be used to create a openapi schema from a postman collection. Its a step that a user can do but I would prefer to do this conversion in the background while usingthis tool.

soerenuhrbach avatar Dec 30 '23 11:12 soerenuhrbach

GraphQL Mesh needs to know how requests and responses look like just like OpenAPI spec. Since there is no clear specification for postman collections about the request and response schemas, I don't think this is going to work. Even if there are some parts of postman collection to define some schemas, they are not strict and commonly used. So most of the people would expect GraphQL Mesh to generate a GraphQL schema magically even if there is no clue in the postman collection. But instead, we recommend people to use OpenAPI handler instead after converting the postman collections to an OpenAPI document.

ardatan avatar Dec 30 '23 13:12 ardatan

I would be possible to create the response and responses types based on the given examples (if they were provided).

soerenuhrbach avatar Jan 01 '24 15:01 soerenuhrbach

I created a package that create the openapi schema with all response and request types when using it together with postman-to-openapi:

https://github.com/soerenuhrbach/openapi-schema-types-from-examples

soerenuhrbach avatar Jan 01 '24 16:01 soerenuhrbach

Since I already have a working solution, I will just create a pull request and you can decide what to do with that.

soerenuhrbach avatar Jan 01 '24 16:01 soerenuhrbach

GraphQL Mesh is already able to generate schemas from the examples but even still postman collections are not required to have examples or schemas. So we cannot use them directly as the source of a GraphQL Schema.

ardatan avatar Jan 03 '24 11:01 ardatan