IBM/openapi-to-graphql

Should OASGraph support GraphQL code-generation?

Open

#16 opened on Sep 6, 2018

View on GitHub
 (13 comments) (0 reactions) (0 assignees)TypeScript (215 forks)github user discovery
enhancementhelp wanted

Repository metrics

Stars
 (1,645 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Currently, OASGraph builds up a GraphQL schema including corresponding resolve functions in memory. I think this approach is great for immediately serving the GraphQL interface.

However, having the GraphQL schema in-memory only also has drawbacks:

  • In some settings, the GraphQL schema needs to be re-generated repeatedly. For example, in serverless, it needs to be re-generated for every invocation, which adds around 100 ms for a relatively small OAS.
  • Generated schemas can mostly be used as-is. However, OASGraph may also be considered a starting point for developers to create a GraphQL interface, which they can then extend and maintain.

In consequence, it may be desirable for a library like OASGraph or thereupon-based tools to output source code instead.

One question is whether this would require a dedicated, separate effort, or can be integrated with a library like OASGraph? On the one hand, generating code requires different capabilities from those supported by OASGraph, including templating and writing to file. On the other hand, capabilities present in OASGraph may be re-usable, for example the schema already produced by OASGraph could simply be stringified, or sanitation mappings could be reused.

Contributor guide