Report a GraphQL Bug
alpha does not communicate with lambda when using @lambdaOnMutate
Expected behaviour and actual result.
when running any delete, add, update
query on any type with @lambdaOnMutate(add: true, update: true, delete: true)
corresponding lambda webhook function does not get triggered.
but when I make a POST request to check lambda works fine and logs somthing {}
This is the POST-request
{
"resolver": "user.add",
"parent": [
{
"User": "0x2"
}
]
}
What edition and version of Dgraph are you using?
community edition ,dgraph/dgraph:latest
and dgraph/dgraph-lambda:latest
Edition:
- SlashGraphQL
- [x ] Dgraph (community edition/Dgraph Cloud)
If you are using the community edition or enterprise edition of Dgraph, please list the version:
Dgraph Version
$ dgraph version
Dgraph version : v22.0.1
Dgraph codename : dgraph
Dgraph SHA-256 : 52c4ae7b827c72a04325af9659642c099faf8f2d7dcb2f2326f777b78cd3b749
Commit SHA-1 : 7fb5291
Commit timestamp : 2022-11-11 04:13:12 +0000
Branch : release/v22.0.1
Go version : go1.18.5
jemalloc enabled : true
For Dgraph official documentation, visit https://dgraph.io/docs.
For discussions about Dgraph , visit http://discuss.dgraph.io.
For fully-managed Dgraph Cloud , visit https://dgraph.io/cloud.
Licensed variously under the Apache Public License 2.0 and Dgraph Community License.
Copyright 2015-2021 Dgraph Labs, Inc.
Have you tried reproducing the issue with the latest release?
yes, the same result
Steps to reproduce the issue (paste the query/schema if possible)
Run this query with with this schema and and lambda setup.
query
mutation{
addDefultCollection(input:{name:"Soo"}){defultCollection{id,type:name},numUids}
}
schema
type Account {
id: ID
type: String
provider: String @search(by: [hash])
providerAccountId: String @search(by: [hash])
refreshToken: String
expires_at: Int64
accessToken: String
token_type: String
refresh_token: String
access_token: String
scope: String
id_token: String
session_state: String
user: User @hasInverse(field: "accounts")
}
type Session @lambdaOnMutate(add: true, update: true, delete: true) {
id: ID
expires: DateTime
sessionToken: String @search(by: [hash])
user: User @hasInverse(field: "sessions")
}
type User @lambdaOnMutate(add: true, update: true, delete: true) {
id: ID
createdAt: DateTime
name: String @search(by: [fulltext, exact])
email: String @search(by: [hash])
emailVerified: DateTime
image: String
description: String
posts: [Post] @hasInverse(field: "user")
accounts: [Account] @hasInverse(field: "user")
sessions: [Session] @hasInverse(field: "user")
createdCollections: [UserCratedCollection] @hasInverse(field: "user")
}
# ...---------Collection----------- ... #
interface Collection {
id: ID!
}
interface CollectionEntry {
id: ID!
img: String!
}
# ...______User Created______
type UserCratedCollection implements Collection {
createdAt: DateTime
name: String! @search(by: [fulltext])
entry: [UserCratedCollectionEntry]! @hasInverse(field: "userCratedCollection")
user: User! @hasInverse(field: "createdCollections")
}
type UserCratedCollectionEntry implements CollectionEntry {
name: String!
discription: String
externelLink: String
createdAt: DateTime
userCratedCollection: UserCratedCollection! @hasInverse(field: "entry")
}
# ...______defualt______
enum DefultCollectionNames {
ANIME
MANGA
CHARACTER
}
type DefultCollection implements Collection
@lambdaOnMutate(add: true, update: true, delete: true) {
name: String! @id
# ... later crete it on lamda mutai
}
type DefultCollectionEntry implements CollectionEntry {
collection: DefultCollection!
providersIdentifer: String!
}
union CollectionEntryUnion = DefultCollectionEntry | UserCratedCollectionEntry
union CollectionUnion = DefultCollection | UserCratedCollection
type Post {
id: ID
name: String! @search(by: [fulltext, exact])
createdAt: DateTime
description: String!
entry1: CollectionEntryUnion!
entry2: CollectionEntryUnion!
entry3: CollectionEntryUnion!
entry4: CollectionEntryUnion!
entry5: CollectionEntryUnion!
entry6: CollectionEntryUnion!
entry7: CollectionEntryUnion!
entry8: CollectionEntryUnion!
entry9: CollectionEntryUnion!
collection: CollectionUnion!
user: User! @hasInverse(field: "posts")
}
type VerificationToken {
id: ID
identifier: String @search(by: [hash])
token: String @search(by: [hash])
expires: DateTime
}
lambda.js
async function updateTimestamps({ event, dql, graphql }) {
console.log("somthing", event);
}
self.addWebHookResolvers({
"User.add": updateTimestamps,
"User.update": updateTimestamps,
"User.delete": updateTimestamps,
});
self.addWebHookResolvers({
"Session.add": updateTimestamps,
"Session.delete": updateTimestamps,
"DefultCollection.add": updateTimestamps,
"DefultCollection.delete": updateTimestamps,
});
configuration
version: "3.2"
services:
zero:
image: dgraph/dgraph:latest
volumes:
- zero:/dgraph
ports:
- 5080:5080
- 6080:6080
restart: on-failure
command: dgraph zero --my=zero:5080
alpha:
image: dgraph/dgraph:latest
environment:
DGRAPH_ALPHA_GRAPHQL_LAMBDA_URL: "http://localhost:8686/graphql-worker"
volumes:
- alpha:/dgraph
ports:
- 8080:8080
- 9080:9080
restart: on-failure
command: dgraph alpha --my=alpha:7080 --zero=zero:5080 --security " token=${DEV_DGRAPH_GRAPHQL_KEY} ; whitelist=0.0.0.0/0 " --cache size-mb=1024 --graphql lambda-url=http://localhost:8686/graphql-worker
graph_lambda:
image: dgraph/dgraph-lambda:latest
ports:
- "8686:8686"
depends_on:
- alpha
volumes:
- type: bind
source: ./lambda/lambdas.js
target: /app/script/script.js
read_only: true
environment:
DGRAPH_URL: http://host.docker.internal:8080
ratel:
image: dgraph/ratel:latest
ports:
- 8000:8000
command: dgraph-ratel
volumes:
zero:
alpha: