问题描述
这是我的GraphQl查询/突变.
我遇到了错误: GraphQLerror:语法错误:预期:,找到{
我不知道其中哪一个是错误的.
import gql from 'graphql-tag'; export const CategoriesQuery = gql` query categoriesQuery( $id: ID!, $country: String!, $name: String! ) { sections( id: $id, country: $country, name: $description ) { id, createdBy, createdDate, lastUpdate, name } } `; export const ItemsQuery = gql` query itemsQuery( $id: ID!, $category: String!, $url: String!, $alias: String!, $name: String! ) { items( input { id: $id, category: $category, url: $url, alias: $alias, name: $name } ) { id, createdBy, createdDate, lastUpdate, name, category, url, alias, description } } `; export const AddCategoryMutation = gql` mutation ($category: CategoryInput!) { addCategory(category: $category) { id } } `; export const AddItemMutation = gql` mutation ($item: ItemInput!) { addItem(item: $item){ id } } `;
推荐答案
这是第二个查询.您需要更改此
items( input { id: $id, category: $category, url: $url, alias: $alias, name: $name } )
:
items( input: { id: $id, category: $category, url: $url, alias: $alias, name: $name } )之后加一个结肠
其他推荐答案
在我的情况下,我意识到我忘了添加类型
false:
type Mutation { ... createMentor(mentoremail: String, password: ID) }
true:
type Mutation { ... createMentor(mentoremail: String, password: ID): Mentor }
问题描述
Here are my graphql queries / mutations.
I'm getting the error: GraphQLError: Syntax Error: Expected :, found {
I don't know which one of them is wrong.
import gql from 'graphql-tag'; export const CategoriesQuery = gql` query categoriesQuery( $id: ID!, $country: String!, $name: String! ) { sections( id: $id, country: $country, name: $description ) { id, createdBy, createdDate, lastUpdate, name } } `; export const ItemsQuery = gql` query itemsQuery( $id: ID!, $category: String!, $url: String!, $alias: String!, $name: String! ) { items( input { id: $id, category: $category, url: $url, alias: $alias, name: $name } ) { id, createdBy, createdDate, lastUpdate, name, category, url, alias, description } } `; export const AddCategoryMutation = gql` mutation ($category: CategoryInput!) { addCategory(category: $category) { id } } `; export const AddItemMutation = gql` mutation ($item: ItemInput!) { addItem(item: $item){ id } } `;
推荐答案
It's the second query. You need to change this
items( input { id: $id, category: $category, url: $url, alias: $alias, name: $name } )
To this:
items( input: { id: $id, category: $category, url: $url, alias: $alias, name: $name } )
Add a colon after input
其他推荐答案
In my case I realized that I forgot to add type to function
false:
type Mutation { ... createMentor(mentoremail: String, password: ID) }
true:
type Mutation { ... createMentor(mentoremail: String, password: ID): Mentor }