Resolver response payload returns null

I deployed my custom functions to 8Base.

They worked perfectly locally, but returned null when I tried testing them on the API explorer and another graphql client:

Payload
mutation Mutation {
__typename
validateOtp(deviceId: “1234”, otp: “0000”, phoneNumber: “+1231200001110”) {
error
data {
access_token
scope
id_token
refresh_token
expires_in
token_type
}
}
}

Expected Response

{
“data”: {
“__typename”: “Mutation”,
“validateOtp”: {
error: false,
data: {
access_token:"",
scope:"",
id_token:"",
refresh_token:"",
expires_in:"",
token_type:""
}
}
}
}

Actual Response

{
“data”: {
“__typename”: “Mutation”,
“validateOtp”: null
}
}

This is experienced for all the custom functions that access 3rd party apis within the function, where I add to use async/await.

Hey Akinduko, are you accessing any 3rd party API using an authentication token that’s only stored on your local machine?

Hey Sebastian,

No all 3rd party APIs are accessed via secrets stored as environment variables.

I remembered to update as appropriate in the 8base dashboard.

Hey Akinduko - I think what’s happening is that there is a disconnect between your custom resolver’s schema and the object returned in your resolver.

Know that the consoled response when running your resolver locally is NOT the schema response but the entire object returned by the resolver function.

Can you share below the resolver functions response schema as well as the shape of the object you return in your handler function?

This file was generated using 8base CLI.

To learn more about writing custom GraphQL resolver types, visit

the 8base documentation at:

https://docs.8base.com/8base-console/custom-functions/resolvers

type OtpSuccess {

success: Boolean!

}

type SendOtpResult {

data: OtpSuccess

error: Boolean

}

extend type Mutation {

sendOtp(phoneNumber: String!, deviceId: String!): SendOtpResult
}

My result:

{
“data”: {
“success”: true
},
“error”: false
}

Hey Akinduko - the data and error properties are implicit. Try dropping the SendOtpResult and just using the Otp success and it should work.

type SendOtpResult {
  success: Boolean!
}

extend type Mutation {
  sendOtp(...): SendOtpResult
}

Update your function response like so:

{
  “data”: {
    “success”: true
  },
  “error”: []
}

Thank you Sebastian,

Your answer was helpful to fix the issue.

Regards.

1 Like