Hi there. I’m trying to setup my app’s user registration, but can’t seem to get my createUser GraphQL mutation to return the created user and associated token secret that I plan on sending to the user to verify their email. The user document and associated token appear to be created in the DB, but the mutation returns null values for both. I’m still finding my footing with FQL / GraphQL, so I’m probably missing something silly
Below is a simplified version of my GraphQL schema that still reproduces the issue
type Mutation {
createUser(input: CreateUserInput!): AuthPayload @resolver(name: "create_user")
}
type User {
username: String! @unique(index: "user_by_username")
email: String! @unique(index: "user_by_email")
verified: Boolean!
}
input CreateUserInput {
username: String!
email: String!
password: String!
}
type AuthPayload {
token: String
user: User
}
And here is my create_user UDF resolver
Query(
Lambda(
["input"],
Let(
{
user: Create(Collection("User"), {
credentials: { password: Select("password", Var("input")) },
ttl: TimeAdd(Now(), 60, "minutes"),
data: {
username: Select("username", Var("input")),
email: Select("email", Var("input")),
verified: false,
}
}),
verificationToken: Create(Tokens(), {
instance: Select(["ref"], Var("user")),
ttl: TimeAdd(Now(), 60, "minutes")
})
},
{
token: Select("secret", Var("verificationToken")),
user: Select("data", Var("user"))
}
)
)
)
You can see that when I try to run the mutation through the GraphQL playground, I just get null values back
Though the document was successfully created when I look at the User collection
{
"ref": Ref(Collection("User"), "300164913489248776"),
"ts": 1622518418880000,
"ttl": Time("2021-06-01T04:33:38.530704Z"),
"data": {
"username": "notarealuser",
"email": "notareal@email.com",
"verified": false
}
}
And if I try running the create_user UDF directly from the shell, it looks like it’s returning valid data? Guessing I’m missing something obvious with how to access those return values via the GraphQL mutation, hmm…
Call("create_user", {"username":"x", "email": "x@fakeemail.com", "password": "12345678"})
{
token: "fnEEKqfZAeACCgQO9FnlkAYNR9kiLRhE58GMeq6nm6tQnaAZreo",
user: {
username: "x",
email: "x@fakeemail.com",
verified: false
}
}
>> Time elapsed: 401ms