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

Restructure `build` for building GraphQLSchema

Open migueloller opened this issue 8 years ago • 1 comments

There are various problems when trying to build a schema that make the API more confusing.

  • Inferring a schema comes with the problem of it not being intuitive where build will check for the operations. Can they all be type dependencies? Do they all have to be in the AST?
  • Schema must declare directives and types and these cannot be lazily evaluated, meaning that for this particular use case build wouldn't support thunks for type dependencies. This is inconsistent.
  • Finally, because a GraphQL schema does not have a name, it's impossible to deterministically set the schema config via the config argument of build.

Perhaps it would be best to delegate schema creation to a separate function and use build only for types. While it adds an extra function it reduces complexity by separating concerns.

migueloller avatar Sep 06 '16 07:09 migueloller

For the next release (v0.1.0) we'll do the following:

  • Keep schema inference with operations in any combination of AST or type dependencies. Good error messages (#4) are critical for this. ~~We'll remove inferred schemas for simplicity and add it in the future if it's something developers want.~~
  • Good error messages (#4) will be ok for forcing array as type dependencies for schema definitions.
  • Directives and types will be able to be passed on to the schema via __schema.

migueloller avatar Sep 06 '16 16:09 migueloller