Skip to content

Add parse_and_validate() for validating a query without executing it - #1392

Open
ChrisJr404 wants to merge 1 commit into
graphql-rust:masterfrom
ChrisJr404:parse-and-validate
Open

Add parse_and_validate() for validating a query without executing it#1392
ChrisJr404 wants to merge 1 commit into
graphql-rust:masterfrom
ChrisJr404:parse-and-validate

Conversation

@ChrisJr404

Copy link
Copy Markdown

Resolves #726.

Right now there's no way to tell whether a request is a query, mutation or subscription without trying to execute it, which is why juniper_graphql_ws currently has to run both execute and resolve_into_stream and see what works. This adds a parse_and_validate() that runs the same parsing and validation as execute/execute_sync but stops before resolving anything, and returns the OperationType of the operation that would run, so a caller can route to the right executor themselves.

It's purely additive, the existing execute functions are untouched. Added tests covering the three operation types plus the parse, validation and multiple-operations error paths, and a CHANGELOG entry.

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

Successfully merging this pull request may close these issues.

Add support for parsing and validating a query without executing it

1 participant