Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove config validation and implement optional Schema validation instead #148

Closed
vladar opened this issue Aug 12, 2017 · 2 comments
Closed

Comments

@vladar
Copy link
Member

vladar commented Aug 12, 2017

At present we do only very shallow validation of schema types, fields and arguments because of performance considerations.

There is also config validation which is unfortunately too limited because it cannot validate fields defined using Closure.

New schema validation should be split into two steps:

  1. Lightweight structural validation when creating schema and type instances
  2. Optional detailed in-depth validation, including interface implementation checks; field, argument names validation, etc

The latter validation could be performed during build-step or when running CLI commands. It will be disabled by default, same as current config validation.

@vladar
Copy link
Member Author

vladar commented Aug 13, 2017

In the v0.10.0 version, we do have Schema validation (based on assertions). GraphQL\Type\Definition\Config is deprecated, so following should be used instead:

$schema = new Schema([/* my opts */]);
$schema->assertValid(); // this will throw GraphQL\Error\InvariantViolation on errors

Method assertValid should not be used in production environment (because it is expensive) but can be useful during build step or in CLI commands to make sure Schema is defined correctly.

@vladar
Copy link
Member Author

vladar commented Aug 20, 2017

Done in v0.10.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant