When I follow the instructions in dgraph-js/examples/simple/README.md, I get this error when running node index.js:
ERROR: { Error: 2 UNKNOWN: line 3 column 16: Missing colon in type declaration. Got
at Object.exports.createStatusError (/Users/alexnitta/Downloads/dgraph-js/examples/simple/node_modules/grpc/src/common.js:91:15)
at Object.onReceiveStatus (/Users/alexnitta/Downloads/dgraph-js/examples/simple/node_modules/grpc/src/client_interceptors.js:1209:28)
at InterceptingListener._callNext (/Users/alexnitta/Downloads/dgraph-js/examples/simple/node_modules/grpc/src/client_interceptors.js:568:42)
at InterceptingListener.onReceiveStatus (/Users/alexnitta/Downloads/dgraph-js/examples/simple/node_modules/grpc/src/client_interceptors.js:618:8)
at callback (/Users/alexnitta/Downloads/dgraph-js/examples/simple/node_modules/grpc/src/client_interceptors.js:847:24)
code: 2,
metadata: Metadata { _internal_repr: {}, flags: 0 },
details:
'line 3 column 16: Missing colon in type declaration. Got \n' }
Looking at the schema in index.js starting on line 22, I noticed that there are no predicates defined under the Person or School types. They each have what looks like a reference to the predicates defined below, for example:
type School {
name // this seems to reference the `name` defined below
}
name: string @index(exact) .
However, I found that I can resolve this error by adding colons and scalar types within the Person and School type definitions. The full schema that runs without throwing errors is:
const schema = `
type Person {
name: string
age: int
married: bool
loc: geo
dob: datetime
friend: [uid]
school: uid
}
type School {
name: string
}
name: string @index(exact) .
age: int .
married: bool .
loc: geo .
dob: datetime .
friend: [uid] @reverse .
`;
Interestingly, when I use a similar pattern on my own project, it still doesn’t resolve the error. It feels like something changed recently about how the Types work in the JavaScript client that is perhaps buggy.
I’ve tried uploading your second schema to a local dgraph v1.1.0 instance and it worked fine.
I get an error only if I don’t add a newline character at the end of the type declaration.
My guess is you are either looking at an old error message or your code is somehow sending the old schema definition
Thanks for trying that out from your end. I have it working now. I think that somehow the old schema definition was cached because of how my Docker volume is set up. I was able to resolve it by removing the container and its volume and starting without a volume.
I would not have expected this to make a difference, since I was using op.setDropAll(true); before doing op.setSchema(schema);.