Hello, I follow the doc to configure lambda but fail.
docker-composer.yaml
services:
dgraph:
image: dgraph/standalone:latest
environment:
DGRAPH_ALPHA_GRAPHQL_LAMBDA_URL: "http://dgraph_lambda:8686/graphql-worker"
ports:
- "8080:8080"
- "9080:9080"
- "8000:8000"
volumes:
- dgraph:/dgraph
dgraph_lambda:
image: dgraph/dgraph-lambda:latest
ports:
- "8686:8686"
environment:
DGRAPH_URL: http://dgraph:8080
volumes:
- ./gql/script.js:/app/script/script.js
volumes:
dgraph: {}
script.js
const results = await dql.query(`query queryAuthor($name: string) {
queryAuthor(func: type(Author)) @filter(eq(Author.name, $name)) {
name: Author.name
dob: Author.dob
reputation: Author.reputation
}
}`, {"$name": args.name})
return results.data.queryAuthor
}
self.addGraphQLResolvers({
"Query.authorsByName": authorsByName,
})
schema
type Author {
id: ID!
name: String! @search(by: [hash, trigram])
dob: DateTime
reputation: Float
}
type Query {
authorsByName(name: String!): [Author] @lambda
}
add data
mutation{
addAuthor(input:{name:"Ann Author", dob:"2000-01-01T00:00:00Z",reputation:6.6}){
author{
name
reputation
dob
}
}
}
when I query
query {
authorsByName(name: "Ann Author") {
name
dob
reputation
}
}
It will return errors
{
"errors": [
{
"message": "Evaluation of custom field failed because external request returned an error: unexpected error with: 400 for field: authorsByName within type: Query.",
"locations": [
{
"line": 2,
"column": 2
}
]
}
],
"data": {
"authorsByName": []
},
"extensions": {
"tracing": {
"version": 1,
"startTime": "2022-01-18T14:50:43.9974995Z",
"endTime": "2022-01-18T14:50:43.9991573Z",
"duration": 1657800
}
}
}
I use
docker compose up -d
setup the container, then modify script.js to as above. and I inspect into the lambda container, make sure the modified script has updated to the container.
and I checked the schema within insomnia make sure the schema is the right one.
I also restart to lambda container.
I think maybe I have ignored some step. any help will be thanks.