GraphQLError: Syntax Error: Expected :, found {

17,961

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

Share:
17,961

Related videos on Youtube

Jonas Arcangel
Author by

Jonas Arcangel

Updated on June 04, 2022

Comments

  • Jonas Arcangel
    Jonas Arcangel almost 2 years

    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
            }
        }
    `;
    
  • Baganaakh
    Baganaakh over 2 years
    where is that file? on which file ?