To facilitate better answering of questions, if you have a question, please fill in the following info. Otherwise, please delete the template.
What I want to do
Mutate and query data via dgraph lambda
Follow the guidance [charts/charts/dgraph-lambda at master · dgraph-io/charts · GitHub ] (charts/charts/dgraph-lambda at master · dgraph-io/charts · GitHub ) and solution http://discuss.dgraph.io/t/helm-install-dgraph-lambda-failed-to-pull-image-dgraph-dgraph-lambda-v1-2-4/17755 to deploy Dgraph and Lambda, I just found another issue. After finishing the last step of uploading schema, pod my-release-dgraph-alpha-0
crashed with an error message printed in logs of the pods:
dgraph alpha --my=my-release-dgraph-alpha-0.my-release-dgraph-alpha-headless.default.svc.cluster.local:7080 --zero my-release-dgraph-zero-0.my-release-dgraph-zero-headless.default.svc.cluster.local:5080
F0912 16:16:04.948493 1 flags.go:139] superflag: found invalid options in flag: lambda-url=http://my-lambda-dgraph-lambda.default.svc:80/graphql-worker.
valid options: introspection=true; debug=false; extensions=true; poll-interval=1s;
I delete dgraph/lambda and dgraph/dgraph, modified the settings when installing dgraph and redid the following steps.
- deploy dgraph
helm install my-release dgraph/dgraph \
--namespace default \
--set "alpha.extraEnvs[0].name"=lambda \
--set "alpha.extraEnvs[0].value"=url=http://my-lambda-dgraph-lambda.default.svc:80/graphql-worker
- deploy lambda
deploy/dev/dgraph/lambda.yaml is the copy from the code on Github tutorial.
helm install my-lambda dgraph/dgraph-lambda \
--set image.tag=1.2.4 \
--namespace default \
--values deploy/dev/dgraph/lambda.yaml \
--set "env[0].name"=DGRAPH_URL \
--set "env[0].value"=http://my-release-dgraph-alpha-headless.default.svc:8080
- forward dgraph port
kubectl port-forward --namespace default my-release-dgraph-alpha-0 8080:8080
- upload schema
deploy/dev/dgraph/schema.graphql is the copy from the code on Github tutorial.
curl http://localhost:8080/admin/schema --upload-file deploy/dev/dgraph/schema.graphql
Now everything goes well, run:
kubectl get pods
it lists:
NAME READY STATUS RESTARTS AGE
my-lambda-dgraph-lambda-5969cf5cbb-ptssv 1/1 Running 0 2m56s
my-release-dgraph-alpha-0 1/1 Running 0 5m4s
my-release-dgraph-alpha-1 1/1 Running 0 4m45s
my-release-dgraph-alpha-2 1/1 Running 0 4m25s
my-release-dgraph-zero-0 1/1 Running 0 5m4s
my-release-dgraph-zero-1 1/1 Running 0 4m45s
my-release-dgraph-zero-2 1/1 Running 0 4m32s
- Test
Add Author GraphQL body:
mutation MyMutation {
addAuthor(input: {name: "AnnZhang"}) {
numUids
}
}
it suceeded. However, I tried the lambda resolver mutation like this, it failed.
mutation MyMutation {
newAuthor(name: "AnnZ")
}
error message:
“errors”: [
{
“message”: “Evaluation of custom field failed because external request returned an error: unexpected error with: 400 for field: newAuthor within type: Mutation.”,
“locations”: [
{
“line”: 2,
“column”: 3
}
]
}
],