Skip to content

Client-side Query Variable Verification #1289

@nmck257

Description

@nmck257

(I spot-checked docs and other issues and couldn't find anything about this; apologies if I missed something)

Affects spring-graphql:1.4.1.

Consider a graphqlClient.documentName("...").variable(/*...*/).executeSync().toEntity(/*...*/) sequence. It's possible that the values supplied by variable calls will mismatch the set of variables defined for the query in the documentName, like providing a value of the wrong type (eg value null for a variable defined as non-null). Similarly, the query itself might be defined with an unused variable.

Those cases could be detected on the client-side, but, are currently sent over the network to the server anyway. This can yield exceptions like this:

org.springframework.graphql.client.FieldAccessException: Invalid field '', errors: [{message=Validation error (UnusedVariable) : Unused variable 'junk'}]
	at org.springframework.graphql.client.DefaultClientResponseField.toEntity(DefaultClientResponseField.java:106) ~[spring-graphql-1.4.1.jar:1.4.1]

It would be nice to have an option to run client-side variable validation before sending a query, to avoid consuming unnecessary network/server resources.

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues related to config and core supportstatus: declinedA suggestion or change that we don't feel we should currently apply

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions