openapi-to-graphql: Cannot generate grapqhl schema for Stripe API
Describe the bug Not able to generate Graphql Schema with openapi-to-graphql cli using Stripe’s API OAS definition
To Reproduce Steps to reproduce the behavior:
- install the openapi-to-graphql-cli
- try generating schema by running:
openapi-to-graphql https://api.apis.guru/v2/specs/stripe.com/2019-03-14/swagger.json
Expected behavior The graphql server starts with generated Stripe API schema
Actual result Getting the following error:
openapi-to-graphql https://api.apis.guru/v2/specs/stripe.com/2019-03-14/swagger.json(node:54348) ExperimentalWarning: The http2 module is an experimental API.
OpenAPI-to-GraphQL creation event error: Cannot read property 'schema' of null
Additional context Up to date latest OAS Stripe’s spec can be grabbed here: https://github.com/stripe/openapi/blob/master/openapi/spec3.json *same generation result as described above
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 5
- Comments: 26
Commits related to this issue
- Support for oneOf and union types Related to #197 Signed-off-by: Alan Cha <Alan.cha1@ibm.com> — committed to Alan-Cha/oasgraph by Alan-Cha 5 years ago
- Support for oneOf and union types Related to #197 Signed-off-by: Alan Cha <Alan.cha1@ibm.com> — committed to Alan-Cha/oasgraph by Alan-Cha 5 years ago
- Support for oneOf and union types Related to #197 Signed-off-by: Alan Cha <Alan.cha1@ibm.com> — committed to Alan-Cha/oasgraph by Alan-Cha 5 years ago
- Support for oneOf and union types Related to #197 Signed-off-by: Alan Cha <Alan.cha1@ibm.com> — committed to Alan-Cha/oasgraph by Alan-Cha 5 years ago
- Support for oneOf and union types Related to #197 Signed-off-by: Alan Cha <Alan.cha1@ibm.com> — committed to Alan-Cha/oasgraph by Alan-Cha 5 years ago
- Support for oneOf and union types Related to #197 Signed-off-by: Alan Cha <Alan.cha1@ibm.com> — committed to Alan-Cha/oasgraph by Alan-Cha 5 years ago
- Support for oneOf and union types Related to #197 Signed-off-by: Alan Cha <Alan.cha1@ibm.com> — committed to Alan-Cha/oasgraph by Alan-Cha 5 years ago
- Support for oneOf and union types Related to #197 Signed-off-by: Alan Cha <Alan.cha1@ibm.com> — committed to Alan-Cha/oasgraph by Alan-Cha 5 years ago
- Support for oneOf and union types Related to #197 Signed-off-by: Alan Cha <Alan.cha1@ibm.com> — committed to Alan-Cha/oasgraph by Alan-Cha 5 years ago
- Do not throw error for anyOf, oneOf, and not Related to #197 and #248 Signed-off-by: Alan Cha <Alan.cha1@ibm.com> — committed to Alan-Cha/oasgraph by Alan-Cha 5 years ago
- Do not throw error for anyOf, oneOf, and not Related to #197 and #248 Signed-off-by: Alan Cha <Alan.cha1@ibm.com> — committed to IBM/openapi-to-graphql by Alan-Cha 5 years ago
- Clean up Example API server code Signed-off-by: Alan Cha <Alan.cha1@ibm.com> Support for oneOf and union types Related to #197 Signed-off-by: Alan Cha <Alan.cha1@ibm.com> Change type to targetGra... — committed to Alan-Cha/oasgraph by Alan-Cha 5 years ago
- Support for oneOf and union types Related to #197 Signed-off-by: Alan Cha <Alan.cha1@ibm.com> — committed to Alan-Cha/oasgraph by Alan-Cha 5 years ago
- Support for oneOf and union types Related to #197 Signed-off-by: Alan Cha <Alan.cha1@ibm.com> — committed to Alan-Cha/oasgraph by Alan-Cha 5 years ago
- Support for oneOf and union types Related to #197 Signed-off-by: Alan Cha <Alan.cha1@ibm.com> — committed to IBM/openapi-to-graphql by Alan-Cha 5 years ago
Hey everyone! I know this has been a very, very long awaited feature but it is finally out. We have support for
allOf,anyOf,oneOf, andnotas well as more robust fallback mechanisms and we can officially say that we can wrap the Stripe API in GraphQL with the release of OtG v2.0.0!In the screenshot, you can see that we are able to successfully run a query against the Stripe API.
Let me know what your experience is! Thanks for sticking around!
I found the problem. OAS uses a few keywords to combine schemas, namely “oneOf”, “anyOf”, “allOf”, and “not”. Currently OtG only supports “allOf”. Stripe makes use of (at least) “anyOf”.
These keywords throw a wrench in the GraphQL ecosystem. Because GraphQL enforces a strong typing system and combining schemas muddles the typing. Implementing “allOf” is easy to do, but “oneOf” and “anyOf” are tricky, and “not” may be impossible (we will probably resort to stringifying the data or use the GraphQL JSON type). For more information, see #14.
For the time being, I have improved reporting with #199.
Hey everyone, first of all, I just wanted to sincerely apologize for keeping you all waiting, making promises that I could not follow through. I honestly feel very bad about it.
I’ve tried multiple times to support this feature but every time, my solution was not comprehensive enough or I would underestimate the complexity of this problem. I also had an influx of other work and could not keep focus all my energy on this issue.
Excuses aside, I’ve made a small patch release (version 1.6.1) that would prevent OtG from throwing an error. Honestly, this is the way it should have been from the beginning.
We still do not support
anyOf,oneOf, andnot; it is a work in progress. At least, for now, we should still produce something.Please update your packages and let me know if the generation still works or if there are any other significant problems that I need to look into.
If you would like to help out, please reach out! We’re always looking for new contributors and maintainers. Even if all you can do is talk, I would love any advice on resolving this problem and any others in the future.
@pktippa I am currently working on a PR #232 that will hopefully be able to address this issue. I plan on checking it in tomorrow and creating a new release. For the time being, you can try to remove the
notproperty in the OAS.I think I’ll take a look at it later in the week! I experimented with a number of APIs on APIs.guru and a number of APIs used these keywords so it seems to be a common problem. Will report back!
Thanks for looking into this issue quickly @Alan-Cha. We’re looking to combine Stripe <> Hasura <> KintoHub and work together on creating easy-to-deploy swagger => graphql containers.
We can begin integration as soon as next week if things turn out positive on your end. Will be watching this thread closely 😃.