Hi,
I have trouble with GraphQL and schema. I will give here all my mess, in hope that will help you what makes this unwanted behavior.
docker-compose file:
version: "3.2"
services:
zero:
image: dgraph/dgraph:latest
volumes:
- /data/zero4:/dgraph2
ports:
# - 5080:5080
- 6082:6080
restart: on-failure
command: dgraph zero --my=zero:5080
alpha:
image: dgraph/dgraph:latest
volumes:
- /data/server14:/dgraph
ports:
- 8082:8080
- 9082:9080
restart: on-failure
command: dgraph alpha --my=alpha:7080 --zero=zero:5080 --security whitelist=172.17.0.0:172.30.0.0,192.168.0.0,192.168.64.1,192.168.32.1,192.168.80.1,192.168.96.1,192.168.0.1,192.168.1.1:192.168.250.1,172.22.0.0,172.23.0.1 --graphql lambda-url=http://lambda:8686/graphql-worker
ratel:
image: dgraph/ratel:latest
ports:
- 8000:8000
command: dgraph-ratel
graphQL schema:
type Usr {
email: String! @id @search(by: [hash])
name: String
sec: Idd @hasInverse(field: user)
}
interface Idd {
user: Usr!
ss: String
}
curl query:
curl --location --request POST 'localhost:8082/graphql' \
--header 'X-Auth-Token: eyJraWQiOiJ6c1wv....' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"mutation {\n addUsr (input: {name: \"z\", email:\"a@b.com\", sec: {ss:\"text\"}}) {\n usr {\n email\n name\n sec {\n user {\n email\n }\n ss\n }\n }\n }\n}","variables":{}}'
response:
{
"errors": [
{
"message": "mutation failed, couldn't commit transaction because rpc error: code = Aborted desc = Transaction has been aborted. Please retry",
"path": [
"addUsr"
]
}
],
"data": {
"addUsr": null
},
"extensions": {
"touched_uids": 9,
"tracing": {
"version": 1,
"startTime": "2021-11-08T07:25:12.49842297Z",
"endTime": "2021-11-08T07:25:12.500813968Z",
"duration": 2390997,
"execution": {
"resolvers": [
{
"path": [
"addUsr"
],
"parentType": "Mutation",
"fieldName": "addUsr",
"returnType": "AddUsrPayload",
"startOffset": 65849,
"duration": 2320586,
"dgraph": [
{
"label": "preMutationQuery",
"startOffset": 85604,
"duration": 679206
},
{
"label": "mutation",
"startOffset": 796100,
"duration": 767918
},
{
"label": "query",
"startOffset": 0,
"duration": 0
}
]
}
]
}
}
}
}
How to produce the bug:
- Start docker-compose file: docker-compose up
- Update schema: curl -X POST localhost:8082/admin/schema --data-binary ‘@schema.graphql’
- Wait 5 minutes and trigger curl graphQL request, and there should be an error
Implications:
- After that the bug occurs, it is not possible to update schema or make any grapQL queries.
- Restart of docker-compose necessary, but sometimes the schema is lost (the schema is visible in ratel, but curl queries returns that there is no schema. Not always)
Dgraph version:
v21:03 Rocket