GraphQL error extension codes

Hello :wave:

I’ve been looking for a list of error codes returned by the GraphQL endpoint, for example, when input contains a non unique instance for a field with a @unique directive.

I have discovered this particular example gives an “instance not unique” code but wondered what the others were?

Hey @jjenzz and terribly sorry to answer your question so late. I’m not on the engineering side so I might not have the perfect answer but I can tell you this. There are a number of errors which are GraphQL specific errors as you can find in our documentation (GraphQL endpoints | Fauna Documentation):

The error codes you are seeing are errors coming from FQL (GraphQL translates to FQL one on one). We should document these thoroughly but in the meantime I’ll attempt to write down a list of error codes as good as I can.

Error codes probably relevant to GraphQL.

  • "transaction aborted": transaction was aborted, could be multiple reasons, the error will explain why. Could also be intended, e.g. when the developer has written a UDF resolver that calls Abort().
  • "invalid token"
  • "permission denied": If I’m not mistaking, valid token but not enough permissions for the requested data or mutations.
  • "instance already exists": If I’m not mistaking, would trigger if you try to create a document with a reference that exists. Could also be a collection/function/index… with the same name.
  • "instance not unique": Error when an index defines a uniqueness constraint by setting unique:true and the uniqueness constraint is not respected upon writing.
  • "invalid ref": Trying to get a reference when the reference doesn’t exist.

Error codes probably (not 100% certain) relevant to GraphQL via UDF resolvers.

  • "value not found": Not entirely sure if that’s the only case but this triggers when trying to use a Select() without a default and that value does not exist.
  • "instance not found": Iirc, trying to retrieve a value from an index when the index didn’t find anything.
  • "missing identity": Trying to use ‘CurrentIdentity()’ when there is no identity (without first checking that with HasCurrentIdentity()).
  • "feature not available"

Error codes probably (not 100% certain) only relevant when directly calling Fauna with FQL.

  • "invalid expression": badly formatted FQL.

The above is based on my experience and is provided temporarily to help you out in case it’s still needed, I will work with docs/eng to get this documented.