graphql query requires named query / mutation
tianhuil opened this issue · comments
Describe the bug
Using the graphql query
doesn't work if the query / mutation are unnamed.
Error Using the graphql query
doesn't work if the query / mutation are unnamed:
$ graphql -p project query query.graphql
✖
Cannot read property 'value' of undefined
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
where query.graphql
is
query {
users {
id
}
}
To work properly: To get a query to work, you need to name the query / operation and pass the operation name in
$ graphql -p project query query.graphql -o User
{
"data": {
"user1": {
"id": "cjq3eeugq000q0b10nppy1926"
},
"user2": {
"id": "cjq3eeumq00100b10blf05m3i"
}
}
}
Done in 2.22s.
where query.graphql
is
query User {
users {
id
}
}
Expected behavior
I would expect a more descriptive error message than Cannot read property 'value' of undefined
, perhaps "Can only use named query with graphql-cli"
.
Context: similar to:
We've just released a new alpha versions channel for GraphQL CLI - 4.0.0-alpha.XXX
!
It was a complete rewrite of the library.
We currently haven't migrated the query
command in our new alpha versions because we want to first hear about the use cases you are using that command for.
Could you please elaborate on that use case here, on a new issue or on our Discord channnel?
Thank you!
I've posted the wrong Discord link, this is the correct one: https://discord.gg/xud7bH9