# Can't rewrite mutation update GQLSchema because input Unexpected

**URL:** <https://discuss.dgraph.io/t/cant-rewrite-mutation-update-gqlschema-because-input-unexpected/7217>\
**Category:** GraphQL\
**Created:** [June 15, 2020, 10:32pm UTC](https://discuss.dgraph.io/t/cant-rewrite-mutation-update-gqlschema-because-input-unexpected/7217 "2020-06-15T22:32:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [June 15, 2020, 10:32pm UTC](https://discuss.dgraph.io/t/cant-rewrite-mutation-update-gqlschema-because-input-unexpected/7217/1 "2020-06-15T22:32:32Z")

</div>

Following the tutorial from: [https://graphql.dgraph.io/quick-start/](https://graphql.dgraph.io/quick-start/)

I start up Docker in Windows and create a schema.graphql file and then try to use curl to import the schema into Dgraph and I get the following error:

> {“errors”:[{“message”:“couldn’t rewrite mutation update"Error”}}]}GQLSchema because input:1: Unexpected \u003cInvalid\u00\>3e\n",“extensions”:{“code”:“Error”}}]}

I even went to the Twitch video posted on youtube with Michael Compton and Kurt Kemple where they built the ToDo app and followed it exactly and I get the error but they don’t.

Example schema.graphql file:

```auto
type User {
  username: String! @id
  todos: [Todo] @hasInverse(field: user)
}

type Todo {
  id: ID!
  description: String!
  completed: Boolean
  user: User!
}

```

I do not understand what the error is and what is Unexpected.

I went into the Dgraph UI and tried to bulk edit the schema directly using the above and I get the error:

> Could not alter schema: line 2 column 20: Expected new line after field declaration. Got @

It seems that the @ directives are not being understood correctly. Can someone help me understand what I am missing here.

---

<div class="post-metadata">

**Author:** ![JatinDevDG](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/jatindevdg/32/3417_2.png) [@JatinDevDG](https://discuss.dgraph.io/u/JatinDevDG)\
**Post date:** [June 15, 2020, 11:55pm UTC](https://discuss.dgraph.io/t/cant-rewrite-mutation-update-gqlschema-because-input-unexpected/7217/2 "2020-06-15T23:55:55Z")

</div>

Hi [amaster507](http://discuss.hypermode.com/u/amaster507) ,  
what version of dgraph are you using ?

i guess this error gets triggered when there is some syntax error in schema.  
Make sure you are using this command  
`curl -X POST localhost:8080/admin/schema -d '@schema.graphql'`

You can try to drop the schema and data from dgraph UI, if possible.

Above schema is of graphql and dgraph UI is for graphql±, so it won’t be able to recognise the syntax of graphql.  
You can use any of graphql client like graphql-playground/insomnia/postman etc. for that.

---

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [June 16, 2020, 12:12am UTC](https://discuss.dgraph.io/t/cant-rewrite-mutation-update-gqlschema-because-input-unexpected/7217/3 "2020-06-16T00:12:02Z")

</div>

Hmm, ok. That command looks like what I was using.

So I guess I am not quite sure still the difference between versions. I will pick this back up in the morning with fresh eyes and brain and try again. Thank you. Is there somewhere that lays out the differences between getting started with dgraph with graphql vs. graphql±

---

<div class="post-metadata">

**Author:** ![abhimanyusinghgaur](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/abhimanyusinghgaur/32/2980_2.png) [@abhimanyusinghgaur](https://discuss.dgraph.io/u/abhimanyusinghgaur)\
**Post date:** [June 16, 2020, 5:29am UTC](https://discuss.dgraph.io/t/cant-rewrite-mutation-update-gqlschema-because-input-unexpected/7217/4 "2020-06-16T05:29:32Z")

</div>

Yeah! looks like there is something wrong with the GraphQL schema you are supplying.  
Can you copy/paste the schema here?

I understand the error message is not very useful in this case, it doesn’t tell what is exactly wrong.

---

<div class="post-metadata">

**Author:** ![gja](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/gja/32/2654_2.png) [@gja](https://discuss.dgraph.io/u/gja)\
**Post date:** [June 16, 2020, 10:37am UTC](https://discuss.dgraph.io/t/cant-rewrite-mutation-update-gqlschema-because-input-unexpected/7217/5 "2020-06-16T10:37:37Z")

</div>

@amaster507 could you have accidently copied some unicode characters wherever you’ve copied the schema from?

---

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [June 16, 2020, 12:53pm UTC](https://discuss.dgraph.io/t/cant-rewrite-mutation-update-gqlschema-because-input-unexpected/7217/6 "2020-06-16T12:53:49Z")

</div>

Ok here are the exact steps I followed:

1. `docker run -it -p 8080:8080 dgraph/standalone:v20.03.1`
2. Copied this code and saved it to a file at `src/schema.graphql`:

```auto
type Product {
    productID: ID!
    name: String @search(by: [term])
    reviews: [Review] @hasInverse(field: about)
}

type Customer {
    username: String! @id @search(by: [hash, regexp])
    reviews: [Review] @hasInverse(field: by)
}

type Review {
    id: ID!
    about: Product!
    by: Customer!
    comment: String @search(by: [fulltext])
    rating: Int @search
}

```

1. Tried to post schema through curl: `curl -X POST localhost:8080/admin/schema --data-binary '@src/schema.graphql'`

```auto
Invoke-WebRequest : A parameter cannot be found that matches parameter name 'X'. 
At line:1 char:6
+ curl -X POST localhost:8080/admin/schema --data-binary '@src/schema.g ...      
+ ~~
    + CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], Paramete 
   rBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Comman  
   ds.InvokeWebRequestCommand

```

1. With Insomnia I pointed at `http://localhost:8080/admin` and refreshed the schema then ran:

```auto
query {
  health {
    instance
    address
    status
    group
    version
    uptime
    lastEcho
    ongoing
    indexing
  }
}

```

And received:

```auto
{
  "data": {
    "health": [
      {
        "instance": "zero",
        "address": "localhost:5080",
        "status": "healthy",
        "group": "0",
        "version": "v20.03.1",
        "uptime": 429,
        "lastEcho": 1592311583,
        "ongoing": [],
        "indexing": []
      },
      {
        "instance": "alpha",
        "address": "localhost:7080",
        "status": "healthy",
        "group": "1",
        "version": "v20.03.1",
        "uptime": 432,
        "lastEcho": 1592311583,
        "ongoing": [
          "opRollup"
        ],
        "indexing": []
      }
    ]
  }
}

```

**EDIT** : I just tried to use a mutation to upload same schema (after removing line breaks) and it worked with the following mutation:

```auto
mutation {
  updateGQLSchema(
    input: {
      set: {
        schema: "type Product { productID: ID! name: String @search(by: [term]) reviews: [Review] @hasInverse(field: about) } type Customer { username: String! @id @search(by: [hash, regexp]) reviews: [Review] @hasInverse(field: by) } type Review { id: ID! about: Product! by: Customer! comment: String @search(by: [fulltext]) rating: Int @search }"
      }
    }
  ) {
    gqlSchema {
      id
      schema
      generatedSchema
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![vardhanapoorv](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/vardhanapoorv/32/2441_2.png) [@vardhanapoorv](https://discuss.dgraph.io/u/vardhanapoorv)\
**Post date:** [June 16, 2020, 1:27pm UTC](https://discuss.dgraph.io/t/cant-rewrite-mutation-update-gqlschema-because-input-unexpected/7217/7 "2020-06-16T13:27:37Z")

</div>

Hi @amaster507  
The error is coming from the fact that `Invoke-WebRequest` command got invoked since by default the alias curl points to that in powershell. You should remove it

```auto
Remove-item alias:curl

```

Then execute the command again and it will use curl(if that’s installed) now.  
Note: Store it in your profile, otherwise you will need to remove it every time.

---

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [June 16, 2020, 1:42pm UTC](https://discuss.dgraph.io/t/cant-rewrite-mutation-update-gqlschema-because-input-unexpected/7217/8 "2020-06-16T13:42:00Z")

</div>

@vardhanapoorv Thank you so much! So I was seeing the problem when many other people were not because 1) I was on Windows, 2) using Powershell, and 3) have installed curl. That makes more sense. I created a profile and added this command to that so I do not have to do it every time.

[https://github.com/lukesampson/scoop/issues/56#issuecomment-609098474](https://github.com/lukesampson/scoop/issues/56#issuecomment-609098474)
