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

3

9

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?

Finned answered 29/11, 2018 at 17:56 Comment(0)
C
12

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

Cristionna answered 27/1, 2020 at 19:47 Comment(1)
Thank you for that! It made me almost crazy. The distinction of the tabs between Query Variables and HTTP Headers is very bad and different from the tab type at the top side.Pyrotechnic
S
7

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.

Stefaniastefanie answered 30/11, 2018 at 2:53 Comment(2)
I want to pass mutation input from query variable tab. How can I pass it without getting type error.Finned
Thank you! For some reason it never occurred to me that there was a difference...Tonga
S
0

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

provide values inside QUERY VARIABLE it solves your issues

Streamliner answered 22/4, 2023 at 3:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.