Skip to content

Feature release: Query Validation

Compare
Choose a tag to compare
@wravery wravery released this 08 Mar 18:21
3ca273a

This is a comprehensive fix for #69. Per the spec, the service ought to validate every query before execution to make sure the results are not ambiguous.

There may still be runtime field errors that this doesn't catch, and since the last time I looked at that section of the spec there also seems to be a lot more guidance about how to format the errors. I added locations to all of the errors I could, and a path to the runtime field errors.

In the process of building the validation feature with TDD based on the Examples and Counter Examples in the spec, I found a few bugs in SchemaGenerator as well and fixed those. The validation relies on Introspection and helped flush those out.

Validation can be performed separately with Request::validate, or you can use the new Request::resolve overloads which take a peg::ast& query parameter instead of a const peg::ast_node& root parameter, they will make sure the query is validated once before executing it. The old Request::resolve overloads are still there for backwards compatibility, but they have been marked as [[deprecated]]. They will go away the next time there's a major version release.