updateGQLSchema returns Unexpected \u003cInvalid\u003e\n


Problems with posting schema

Dgraph Version
$ dgraph version
 
Master

Have you tried reproducing the issue with the latest release?

Same problem with Master version and v20.11.1

Steps to reproduce the issue (command/config used to run Dgraph).

So i run the dgraph docker oneliner to setup dgraph.

docker run -it -p 8080:8080 dgraph/standalone:master

After that just normal create-react-app and added a schema.graphql file in src/ that contains the following:

type User {
  username: String! @id
  characters: [Character] @hasInverse(field: user)
}

type Character {
  id: ID!
  name: String!
  race: String!
  user: User!
}

And finally i ran the push schema command:

curl -X POST localhost:8080/admin/schema --data-binary '@schema.graphql'

At this point its textbook everything is correct and good. The result it gives me is following:

{
 "errors":[{
     "message":"resolving updateGQLSchema failed because input:1: Unexpected \u003cInvalid\u003e\n (Locations: [{Line: 3, Column: 4}])",
     "extensions":{"code":"Error"}
 }]
}

I tried it with simple schema with same result.

type User {
  username: String
}

I tested it with another react enviroment and two different versions of dgraph.
The dgraph docer log shows that the server received the post.

I0218 11:32:16.126655 36 middlewares.go:178] GraphQL admin mutation. Name = updateGQLSchema
I0218 11:32:16.126691 36 schema.go:51] Got updateGQLSchema request

What could cause this error and how can i get rid of it? Please help a fellow coder out.

does this help: Error updating schema with @custom directive ?

No i tried to solutions in that post but i think its not the same problem.

maybe there is some “invisible character” in the schema file, something like a control character?
There must be some character not supported by the spec, that is the reason it is not parsing the schema.

i have tried it many times over and atleast the schema.graphql file has no odd characters. Is it possible that something that handles the encoding adds some odd things to it?

OK i created an empty text file and named it schema.graphql and added my schema there. Then with terminal i tried to push it and it went in… What is wrong with my vscode and terminal? Also with git bash terminal it works. But not with vscode terminal.

1 Like

What is your OS? What version of VSCode? What terminal in VS Code are you using?

I use the Shell launcher VS Code extension to run different shells from terminal in VS Code, I am windows so I can run cmd, Powershell, and also have installed Git bash, and WSL bash :wink:

In VSCode terminal you can also change your default shell: F1 > Terminal: Select Default Shell

1 Like

For me I was missing an @ before schema.graphql. I don’t know what the @ does?

I tried, but it didn’t solve the problem. Is there any other way。

Thank you. I opened my Bash Cmd on the Windows. Go to need catalog and use post graphQL schema. It works.
image