2017-12-11 10 views
0

GraphQL을 처음 사용하여 GraphiQL을 통해 쿼리를 보내는 데 문제가 있습니다.GraphQL, GraphiQL을 사용하는 쿼리의 구문이 잘못되었습니다.

이 내 schema.js

const graphql = require('graphql'); 
const _ = require('lodash'); 
const{ 
    GraphQLObjectType, 
    GraphQLInt, 
    GraphQLString, 
    GraphQLSchema 
} = graphql; 

const users = [ 
    {id:'23', firstName:'Bill', age:20}, 
    {id:'47', firstName:'Samantha', age:21} 
]; 

const UserType = new GraphQLObjectType({ 
    name: 'User', 
    fields:{ 
     id: {type: GraphQLString}, 
     firstName: {type: GraphQLString}, 
     age:{type: GraphQLInt} 
    } 
}); 

const RootQuery = new GraphQLObjectType({ 
    name: 'RootQueryType', 
    fields:{ 
     user: { 
      type: UserType, 
      args:{ 
       id: {type: GraphQLString} 
      }, 
      resolve(parentValue, args){ // move the resolve function to here 
       return _.find(users, {id: args.id}); 
      } 
     }, 

    } 
}); 

module.exports = new GraphQLSchema({ 
    query: RootQuery 
}); 

입니다 그리고 내가 graphiql에서 다음 쿼리를 실행하면 나는 "가지고 구문 오류 GraphQL 요청

query { 
    user { 
    id: "23" 
    } 
} 

(3 : 9) 예상 이름, 발견 문자열 ",하지만 난"23 "ID와 사용자를 얻을 것으로 기대합니다.

무엇이 누락 되었습니까?

답변