-
Notifications
You must be signed in to change notification settings - Fork 52
Description
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 .
`;My solution also mirrors what is shown in the docs here: https://docs.dgraph.io/query-language/#type-definition
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.