Custom Lambda does not work anymore!

Hi,

I have created custom lambda which recently did work. For some reason the lambda did stop working. For testing purposes I have created a slimmer version of it, which does not work as well!

Here’s the lambda

export const createTest = async ({ args, graphql, authHeader }) => {
  const test = await graphql(
    `
      mutation add {
        addTest(input: { name: "hello world" }) {
	  numUids
	}
      }
    `
  ); 

  return { result: JSON.stringify(test) }
}

The type Test is simply:

type Test {
  id: ID!
  name: String
}

I have tested the mutation on the cloud which works as intended. Unfortunately the exact same mutation in the lambda does not work. I know that the mutation is getting executed - I have tested to submit an Integer instead of a String for name - here I receive an error message that the field has the wrong type. If the name is a string as above then I get the result data.addTest: { null }.

Usually this means that something with the access is off but I have set all fields and the lambda to *publicly queryable".

Is there a cache or something I can clear? This is driving me mad, I’ve already spent 2 days on this issue!

UPDATE

I’m pretty sure now that this problem is auth related! I have run several tests and if I run the addTest mutation directly from the frontend, it works!

I have checked the permissions again (createTest and test is set to publicly queryable), I guess something is stuck here…

Any help, this is quite important?

Hi Florian,

There was an error in the above line. You would need to change test to results.data to get the mutation to work.

I just wanted to close this issue. Thank’s to @anand’s help I was able to debug my entire Application. Since I am using Relay and Relay Network Modern, I found out that relay was doing some weird requests without a valid API token a split second before the “real request” started. This has caused Dgraph to decline the mutation.

So all my bad!

Sorry and thanks for the help! :raised_hands: