GraphQLError: Syntax Error: Expected Name, found <EOF>
Asked Answered
U

2

68

I got the above error on a graphql query, I am using apollo-react by the way and using the Query component for rendering the data

this is my code

const GET_VEHICLE_CHECKS = gql`
query getVehicleChecks($uuid: String!) {
  tripDetails(uuid: $uuid){
    departmentAssigned{
      vehicleChecks{
        conditions{
          id
          name
          standard
          valueType
          spinnerItems
        }
      }
    }
  }

`;

and this is what my actual query looks like

{
  tripDetails(uuid: "c0e7233093b14afa96f39e2b70c047d8"){
    departmentAssigned{
      vehicleChecks{
        conditions{
          id
          name
          standard
          valueType
          spinnerItems
        }
      }
    }
    vehicleConditions{
      id
      condition{
        id
        standard
      }
      value
    }
  }
}

I tried changing variable names, but that didn't work

Ultravirus answered 2/7, 2019 at 8:4 Comment(0)
A
190

You are missing a closing bracket } at the end of your query.

const GET_VEHICLE_CHECKS = gql`
query getVehicleChecks($uuid: String!) {
  tripDetails(uuid: $uuid){
    departmentAssigned{
      vehicleChecks{
        conditions{
          id
          name
          standard
          valueType
          spinnerItems
        }
      }
    }
  }
} <- THIS
`;
Abiogenesis answered 2/7, 2019 at 9:40 Comment(1)
This was the answer for me. Too bad the person writing this error message didnt have the sense to make a descriptive message. EOF is vague and someone really shouldnt need to do look up what it means to understand.Inveracity
P
0

This error message is usually cause by a missing { or a missing ( so look for that in your query also look for stray/missing :

It could be that your query is empty which will give you the EOF error as well

Poised answered 26/7, 2023 at 19:35 Comment(1)
@EricAya My answer is more general and applicable then the accepted. Plus it adds more informationPoised

© 2022 - 2024 — McMap. All rights reserved.