Was playing around with SlashGraphQL and Lambdas and noticed a bug. To reproduce, do the following:
- Add a schema with the following:
type Task {
id: ID!
title: String! @search(by: [fulltext])
completed: Boolean! @search
user: User!
}
type User {
fullName: String @lambda
username: String! @id @search(by: [hash])
name: String @search(by: [exact])
tasks: [Task] @hasInverse(field: user)
}
- Add a lambda script with the following:
const fullName = () => `hi`
self.addGraphQLResolvers({
"User.fullName": fullName
})
- Then run the following in the API Explorer:
mutation AddTasks {
addTask(input: [
{title: "Create a database", completed: false, user: {username: "your-email@example.com"}},
{title: "Write A Schema", completed: false, user: {username: "your-email@example.com"}},
{title: "Put Data In", completed: false, user: {username: "your-email@example.com"}},
{title: "Complete Tasks with UI", completed: false, user: {username: "your-email@example.com"}},
{title: "Profit!", completed: false, user: {username: "your-email@example.com"}},
{title: "Walking", completed: false, user: {username: "frodo@dgraph.io"}},
{title: "More Walking", completed: false, user: {username: "frodo@dgraph.io"}},
{title: "Discard Jewelery", completed: false, user: {username: "frodo@dgraph.io"}},
{title: "Meet Dad", completed: false, user: {username: "skywalker@dgraph.io"}},
{title: "Dismantle Empire", completed: false, user: {username: "skywalker@dgraph.io"}}
]) {
numUids
task {
id
title
user {
fullName
username
}
}
}
}
You’ll get output like the following:
{
"data": {
"addTask": {
"numUids": 10,
"task": [
{
"id": "0x5b85",
"title": "Write A Schema",
"user": {
"fullName": "hi",
"username": "your-email@example.com"
}
},
{
"id": "0x5b86",
"title": "Walking",
"user": {
"fullName": "hi",
"username": "frodo@dgraph.io"
}
},
{
"id": "0x5b87",
"title": "More Walking",
"user": {
"fullName": null,
"username": "frodo@dgraph.io"
}
},
{
"id": "0x5b88",
"title": "Discard Jewelery",
"user": {
"fullName": null,
"username": "frodo@dgraph.io"
}
},
{
"id": "0x5b89",
"title": "Dismantle Empire",
"user": {
"fullName": "hi",
"username": "skywalker@dgraph.io"
}
},
{
"id": "0x5b8a",
"title": "Create a database",
"user": {
"fullName": null,
"username": "your-email@example.com"
}
},
{
"id": "0x5b8b",
"title": "Put Data In",
"user": {
"fullName": null,
"username": "your-email@example.com"
}
},
{
"id": "0x5b8c",
"title": "Complete Tasks with UI",
"user": {
"fullName": null,
"username": "your-email@example.com"
}
},
{
"id": "0x5b8d",
"title": "Profit!",
"user": {
"fullName": null,
"username": "your-email@example.com"
}
},
{
"id": "0x5b8e",
"title": "Meet Dad",
"user": {
"fullName": null,
"username": "skywalker@dgraph.io"
}
}
]
}
},
"extensions": {
"touched_uids": 147,
"tracing": {
"version": 1,
"startTime": "2021-01-10T13:47:16.207430123Z",
"endTime": "2021-01-10T13:47:16.215849208Z",
"duration": 8419104,
"execution": {
"resolvers": [
{
"path": [
"addTask"
],
"parentType": "Mutation",
"fieldName": "addTask",
"returnType": "AddTaskPayload",
"startOffset": 153151,
"duration": 8188076,
"dgraph": [
{
"label": "mutation",
"startOffset": 469205,
"duration": 4047792
},
{
"label": "query",
"startOffset": 5405383,
"duration": 1237134
}
]
}
]
}
}
}
}
Note: Some of the fullNames are what they should be “hi”, but some are null
. I’m assuming this is a bug right?