Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Variable \"$id\" of required type \"ID!\" was not provided."

I am trying to query by passing the variable id in the query variable window. This results in an error "Variable \"$id\" of required type \"ID!\" was not provided."

a screenshot of GraphQL Playground

When I run a different query without passing a variable in the query variable section it successfully returns results.

a screenshot of GraphQL Playground

Why does one produce an error, but not the other?

like image 370
salahuddin ansari Avatar asked Dec 10 '22 04:12

salahuddin ansari


2 Answers

You have to select the QUERY VARIABLES tab, and put the variable value there. You can check that in the attached image.

enter image description here

like image 63
Guillermo García López Avatar answered Jan 29 '23 07:01

Guillermo García López


In the first screenshot you've typed JSON into the "HTTP Headers" tab, not the "Query Variables" tab. Clear out this section and type the JSON variables object into the correct tab.

like image 27
David Maze Avatar answered Jan 29 '23 06:01

David Maze