Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apollo graphQL unsupported token in input

I am using Apollo Android GraphQL (Gradle plug-in version 1.2.1) to post data to a server. I have downloaded the schema.json file from the server and written a .graphql file with a mutation. To pass objects from the App I defined some input objects as follows.

input Location {
    lat: Float!
    lon: Float!
}

input SensorParams {
    sources: [Int]
    exposition: Float
    location: Location!
}

mutation InsertSessionResults(
    $location: Location!) {
    insertSession(session: {
        name: $name
    }) {
        id
    }
}

However when I build the App, I get the following error: Failed to parse GraphQL file. Unsupported token '!'

If I remove the '!' from Location, the process gives the same error for the '[' char.

Reading the doc I understand that both characters are allowed in input definition to request a non-null value and to set a list type respectively, so what may cause the error?

like image 722
aleGrazioli Avatar asked Sep 19 '25 06:09

aleGrazioli


1 Answers

There is no need to write type definitions in your front end, just write the query as a string. The input types are defined in the schema on the server.

like image 134
Xizam Avatar answered Sep 20 '25 21:09

Xizam