graphql-go-tools icon indicating copy to clipboard operation
graphql-go-tools copied to clipboard

schema validation

Open jensneuse opened this issue 6 years ago • 3 comments

We should add a schema validation thing to find issues like:

  • schema definition missing in schema
  • to be continued...

Also when validating a Query there should be a meaningful message in case the validation errs due to missing schema declaration. A possible solution might be to initialize the operation definition values with "-1".

jensneuse avatar Apr 17 '19 18:04 jensneuse

I think we should respect the spec here and add fallback behaviour as described in the spec: https://github.com/graphql/graphql-spec/blob/master/spec/Section%203%20--%20Type%20System.md#root-operation-types

Default Root Operation Type Names

While any type can be the root operation type for a GraphQL operation, the type system definition language can omit the schema definition when the query, mutation, and subscription root types are named Query, Mutation, and Subscription respectively.

Likewise, when representing a GraphQL schema using the type system definition language, a schema definition should be omitted if it only uses the default root operation type names.

This example describes a valid complete GraphQL schema, despite not explicitly including a schema definition. The Query type is presumed to be the query root operation type of the schema.

Same goes for the builtin scalars: https://github.com/graphql/graphql-spec/blob/master/spec/Section%203%20--%20Type%20System.md#scalars

Built-in Scalars

GraphQL provides a basic set of well-defined Scalar types. A GraphQL server should support all of these types, and a GraphQL server which provide a type by these names must adhere to the behavior described below.

flexzuu avatar Apr 17 '19 21:04 flexzuu

Should support extensions, e.g. in case of custom directives. So extensions should be able to define their own rules/hooks to extend the validation rules manually.

jensneuse avatar Nov 10 '19 14:11 jensneuse

up

it is still an issue

We could get an error in the playground when some type is missing in a schema, but there is no error message in the console

Browser error message:

playground.js:1 Uncaught Error: Invalid or incomplete schema, unknown type: RequestResult. Ensure that a full introspection query is used in order to build a client schema.

devsergiy avatar Jan 20 '20 16:01 devsergiy