Reputation: 307
I'm new to grapghql and my query fails.
I'm using
{
product {
id
}
}
"message": "Field "product" argument "id" of type "String!" is required, but it was not provided."
Thank you for your help
Upvotes: 3
Views: 12016
Reputation: 1171
It looks like you're making a query for a Product
object.
GraphQL queries may require arguments, you can read more about that here.
The error message is telling you that field product
requires argument id
of type String!
.
That means you must know the id
of a Product
and then can query more fields.
Let's assume there is a product with id: "abc42"
. A query then might look like:
{
product(id: "abc42") {
name
}
}
In this query the id
is hardcoded. There are ways to pass the id
dynamically, but that depends on your code and the libraries you are using.
Upvotes: 2