rlindskog / covid19-graphql

COVID-19 GraphQL API
https://covid19-graphql.now.sh/
MIT License
84 stars 22 forks source link

uncaught exception: Syntax Error: Unexpected Name "country" GraphQL request:2:5 #9

Closed bonniesimon closed 4 years ago

bonniesimon commented 4 years ago

I'm getting an error while using this api.

I used apollo to do the querying.


import ApolloClient from 'apollo-boost';
import {gql} from 'apollo-boost';

const client = new ApolloClient({
    uri: 'https://covid19-graphql.now.sh/',
});

client
  .query({
    query: gql`
    country (name: "India") {
        name
      }
    `
  })
  .then(result => console.log(result));

This is the code I used.

The following is the error I get with react:

uncaught exception: Syntax Error: Unexpected Name "country"

GraphQL request:2:5
1 |
2 |     country (name: "India") {
  |     ^
3 |         name
rlindskog commented 4 years ago

Hey, you're query looks a little off, try this

query {
  country(name: "India") {
    name
  }
}

It works in the Graphiql editor, let me know if that works / you have any more questions!

rlindskog commented 4 years ago

@bonniesimon Closing this for now, please reopen if my solution doesn't work or you have any more issues!