facebook / relay

Relay is a JavaScript framework for building data-driven React applications.
https://relay.dev
MIT License
18.24k stars 1.8k forks source link

Experimental feature to validate composite schema #4675

Closed captbaritone closed 1 month ago

captbaritone commented 2 months ago

Currently we do not validate the schema. We assume the schema has been pre-validated. This has been fine historically but with Client Schema Extensions and Relay Resolvers, Relay itself is increasingly contributing GraphQL schema in ways that need to be validated.

This change adds experimental support for validating the schema after it's created. It relies on a pre-existing module generally used for standalone schema validation and has its own scheme for error reporting. Specifically, it does not use Diagnostics which are located at a specific position, but rather derives textual error output itself.

This likely won't play well with out LSP. For now I've added it behind a flag without a real error location. This should let us experiment with the feature and explore how we might update the validation to use Diagnostics directly, or at least be able to.

In some cases the server schema may not actually be persisted to disk, in which case the error reporting approach currently used is likely preferable.

This PR also updates all integration tests with invalid schemas to be valid.

facebook-github-bot commented 2 months ago

@captbaritone has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot commented 1 month ago

@captbaritone merged this pull request in facebook/relay@5273c1972da420f2e40f74df21c7016e6602120b.