Apollo-android: Error when building project

Created on 27 Aug 2019  路  6Comments  路  Source: apollographql/apollo-android

When I'm building the project I'm getting this error:

com.apollographql.apollo.compiler.parser.GraphQLDocumentParseException: 
Failed to parse GraphQL file .../schema.json.graphql (3:7)
Unsupported token `{`

and this is the schema.json file

query {
  getUsers {
    id
    name
    lastName
  }
}
compiler Enhancement Question

Most helpful comment

I solved it! I had a file called schema.graphql that was causing the problems, I removed it and it works. Thanks for the help @sav007

All 6 comments

Yeah probably the message should be more descriptive, but you must provide query name.

I'm still getting the error:

query getUsers {
  getUsers {
    id
    name
    lastName
  }
}

Are you getting the same error?

And I guess you are missing smth:

  1. First of all the file you provided is not schema but a query that probably should be named query.graphql
  2. Schema is a separate schema.json file that GraphQL introspection query gives to you (or backend dev handed it over to you).
  3. At least these 2 files have to be placed under src/*/graphql/com/sample/... folder in your project.

Schema is used to correctly parse your GraphQL queries.

I solved it! I had a file called schema.graphql that was causing the problems, I removed it and it works. Thanks for the help @sav007

I'm getting the error while building too. Here is the error

com.apollographql.apollo.compiler.parser.GraphQLDocumentParseException:
Failed to parse GraphQL file C:\Users\Narayanan KA\Downloads\Android projects\Kickstarter\app\src\main\graphql\activity.graphql (2:35)
Unsupported token }

Was this page helpful?
0 / 5 - 0 ratings