I have a schema defined in graphql:
type User {
username: String! @id
isContact: Contact!
}
type Contact {
id: ID!
name: String
}
I set some data with dgraph:
{
set {
_:user-1 <dgraph.type> "User" .
_:user-1 <username> "anthony" .
_:user-1 <isContact> _:user-1C .
_:user-1C <dgraph.type> "Contact" .
_:user-1C <name> "Anthony Master" .
}
}
Response:
{
"data": {
"code": "Success",
"message": "Done",
"queries": null,
"uids": {
"user-1": "0x3b",
"user-1C": "0x3c"
}
},
"extensions": {
"server_latency": {
"parsing_ns": 22700,
"processing_ns": 258957100,
"assign_timestamp_ns": 773100,
"total_ns": 259846600
},
"txn": {
"start_ts": 687,
"commit_ts": 688,
"preds": [
"1-dgraph.type",
"1-isContact",
"1-name",
"1-username"
]
}
}
}
I can query it with dgraph:
{
User(func: uid(0x3b)) {
uid
username
isContact {
uid
name
}
}
}
Response:
{
"data": {
"User": [
{
"uid": "0x3b",
"username": "anthony",
"isContact": [
{
"uid": "0x3c",
"name": "Anthony Master"
}
]
}
]
},
"extensions": {
"server_latency": {
"parsing_ns": 68400,
"processing_ns": 97505600,
"encoding_ns": 51400,
"assign_timestamp_ns": 817700,
"total_ns": 98492100
},
"txn": {
"start_ts": 692
},
"metrics": {
"num_uids": {
"": 1,
"_total": 6,
"isContact": 1,
"name": 1,
"uid": 2,
"username": 1
}
}
}
}
But if I try to query the same data with graphql (on the 8080 port /graphql where I can read the schema…):
{
queryUser {
username
isContact {
id
name
}
}
}
I get the following response error:
{
"errors": [
{
"message": "Non-nullable field 'username' (type String!) was not present in result from Dgraph. GraphQL error propagation triggered.",
"locations": [
{
"line": 3,
"column": 5
}
],
"path": [
"queryUser",
0,
"username"
]
}
],
"data": {
"queryUser": [
null
]
}
}
Can I not set data with dgraph mutations and then read it with graphql queries?
I have a lot of linking data in ~250Mb dataset that I need to import and link together with nodes dependent on nodes and the best method seems to use dgraphs set function with named nodes as above (but more complex in use case)