salahuddin ansari
salahuddin ansari

Reputation: 95

"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?

Upvotes: 9

Views: 11985

Answers (3)

saigopi.me
saigopi.me

Reputation: 14918

in my case i mistakenly provided query in HTTP HEADERS instead of QUERY VARIABLE,

provide values inside QUERY VARIABLE it solves your issues

Upvotes: 0

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

Upvotes: 12

David Maze
David Maze

Reputation: 158977

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.

Upvotes: 7

Related Questions