Fail when alter Schema

Hi. I am new in dgraph. I tried to alter my Schema follow the docs page:

type Todo {
    id: ID!
    task: String
    owner: Owner

type Owner {
    name: String! @id
    todo: [Todo] @hasInverse(field:"owner")

And I got this error:

Init Schema error: rpc error: code = Unknown desc = while lexing
at line 10 column 35: Invalid schema. Unexpected " 

Next. I tried to make a very simple schema:

type Todo {
    id: ID!
    task: String

Then I got.
Init Schema error: rpc error: code = Unknown desc = Schema does not contain a matching predicate for field id in type Todo

I am using dgraph v21.03.2
Am I using the wrong version? Please let me know.

If I use something like this:

<email>: string @index(exact) .
<first_name>: string .
<last_name>: string .
<password>: string .
type <User> {

It works. This is from the docs of
But I want to use the newest feature on official page of dgraph. Hope someone can help me. Many thanks

I think the problem here is that Dgraph has two types of schema, GraphQL and DQL (i.e. native). Your working example at the end is a DQL schema that can be uploaded with dgo client (dgo exclusively uses the DQL language). The failing examples you are trying above are GraphQL schemas, which must instead be sent via a http request or via the dgraph cloud UI. Would be cool if the dgo client had this ability, but currently it does not.

Both schemas can work together on the same underlying data if needed


Thank you. I will read more docs about this problem

Follow the error message, don’t use quotes in the hasInverse statement.


1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.