version: apollo-codegen 0.15.2
i execute query in graphiql
query { getAllCustomers {id} }
i gets data.getAllCustomers[ids...]
{
"data": {
"getAllCustomers": [
{
"id": "34"
then i want to execute query under apollo-client/angular-apollo
so i continue with codegen
i have only one .gql file with the same query like i executed in graphiql:
query { getAllCustomers {id} }
but schema.ts wont genrate with error
```
.../main/customers/_graphql/getCustomers.gql: Apollo does not support anonymous operations
error: Validation of GraphQL query document failed
````
if found problem query withink works in graphql-tag and gprahiql wont generate type script to solve above problem is add
query SOMESTRING { getAllCustomers {id name symbol} }
then apolo codegen will generate
````
export type SOMESTINGQuery = {
getAllCustomers: Array< {
`````
Yes, we need to name the types we generate so we can't really support anonymous queries.
so the example
query SOMESTRING { getAllCustomers {id name symbol} }
is brilliant.
in the code -
you need to throw a warning and say to users
query INSERTQUERYNAMEHERE { getAllCustomers {id name symbol} }
maybe even link back here
https://github.com/apollographql/apollo-codegen/issues/184
or perhaps you could randomize some name? like heroku?
i think that in my usecase - simply grabbing the first parameter and throwing it as the name / would suffice. Then instead of an error - just throw a warning.
public final class SomestringQuery: GraphQLQuery {
public static let operationString =
"query SOMESTRING {" +
You really MUST report file name where the error happened.
I have app with 50 queries and I really don't want check every file manually
@rricard Do you think we can re-open this issue in light of @langpavel's comment that we need to report the file name where the error occurred. Checking every query manually is an unreasonable solution to this
I was able to debug this by adding temporary logs to the file where the issue was being raised (not the ideal, but it worked for me):
// /usr/local/lib/node_modules/apollo/node_modules/apollo-language-server/lib/project/client.js
if (!definition.name) {
console.log('definition', definition)
console.log('document', document)
}
Document will give you information about the file being evaluated so you will be able to solve the issue!
In my case the error was coming from an old commented out query and I had to remove the comment to get it to work. I was only able to discover this after adding console logging like @giovannibenussi suggested. Would have been a bit easier if there was more information in the output.
/*
const ROUND_LIST = gql`
{
rounds {
...FullRound
}
}
${fullRoundFragment}
`;
*/
Any update on adding tracing so that we can tell which line number, or at least file, is causing the error?
Can we add this tracing? As simple as @giovannibenussi console logging would help a tremendous amount.
I finally figured out my error after printing out the document.
Most helpful comment
You really MUST report file name where the error happened.
I have app with 50 queries and I really don't want check every file manually