question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom validation rules break query argument validation

See original GitHub issue

I try to query a model with the single id parameter The request looks like this: {“operationName”:“GetClient”,“variables”:{“id”:3},“query”:“query GetClient($id: Int!) {\n client(id: $id) {\n node {\n email\n id\n profile {\n phone\n name\n __typename\n }\n __typename\n }\n __typename\n }\n}\n”} Intended outcome: The operation succeeds and returns proper values Actual outcome: The response comes back with a status 400 and the following error: {“errors”:[{“message”:“Argument "id" of required type "Int!" was provided the variable "$id" which was not provided a runtime value.”,“name”:“ValidationError”,“locations”:[{“line”:2,“column”:14}]}]} How to reproduce the issue: Send a single id parameter in query variables to your grapqh-server-express This does happen ocasionally so you may do it several times At some point you will see that the $id is being sent properly, but it does not pass grapqh-server-express validation for some reason

Attaching screenshots from a browser network tab: screen shot 2018-09-07 at 11 14 59 am screen shot 2018-09-07 at 11 15 13 am

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mxstbrcommented, Oct 2, 2018

I’m also running into this error during my upgrade to Apollo Server v2. (ref withspectrum/spectrum#3855 ) I don’t think it has anything to do with it being the single argument though, it happens for us with multiple arguments:

screenshot 2018-10-02 at 15 48 52

screenshot 2018-10-02 at 15 48 57

I think it has something to do with adding custom validationRules. This specific commit broke the build with this error (“Argument “id” of required type “ID!” was provided the variable “$id” which was not provided a runtime value.”): https://github.com/withspectrum/spectrum/pull/3855/commits/0cb181d462dc6c6fb1bd0f000845f3029e3e9eba Before that it was working perfectly fine.

0reactions
martijnwalravencommented, Jul 8, 2019

Closing this because it doesn’t seem like an issue with Apollo Server itself.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GraphQL validation using directives
Receiving validation errors on the client​​ When a consumer sends a request which breaks these rules, the application will respond with an error ......
Read more >
Restrict data input by using validation rules - Microsoft Support
When data is entered, Access checks to see whether the input breaks a validation rule – if so, the input is not accepted,...
Read more >
3 Custom Validation Rules - Oracle Help Center
The most elementary details which are needed to create a validation rule on an entity are description, type, associated error, execution sequence, and...
Read more >
Custom validation involving query - Laracasts
I want to add a validation rule slightly more complex than the ones out of the box. If a user wants to pick...
Read more >
Laravel validations crash course (+ custom validation rule with ...
Validations covered include: - custom error messages - custom validation rules (with parameters ) - max - min - in *** Rule::in() -...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found