Internal server error when passing "null" to a nullable variable

I’m not really sure why this happens. I was under the impression that nullable values were nullable. Am I misunderstanding something?

Hi RamonMamon,

Welcome and thanks for joining the Fauna forums!

Nullable fields can be passed with null as the value. Can you share the schema you’re using? That should give us some more insight into what’s happening.

Thanks,
Cory

Hi Cory,

This is the schema I’m using.

I hope you can figure it out, because I can’t haha

Thanks,
Ramon

In general, explicit nulls are technically different types than implicit nulls (“not provided”), in-so-much that they can be handled differently. See the GraphQL spec. It’s still up to each implementation to deal with separating the two, and then applications to dictate how they are handled.

You tried to pass null to a generated relation field, and it looks like Fauna is not handling this for the case of relations. (It still works for scalars and embedded objects)

Solution/ Workaround

If you are creating a new Document, simply do not provide the relation. If you are updating an existing Document, you need to use the provided disconnect nested mutation.

mutation CreateQuote {
  createQuote(data: { 
    owner: { connect: "1234" }
    text: "this is a great quote"
    favorite: false 
  }) {
    _id
    text
  }
}

mutation UpdateQuote {
  updateQuote(id: "555", data: { 
    book: { disconnect: true } 
  })
}

Feature request

This said, perhaps providing an explicit null to a relation could be ignored in the createX case, work as sugar for disconnect in the updateX case (one-to- relations only), or at least create a more obvious error that what you are attempting is not going to do what you think it is going to do so therefore is aborting the query.

1 Like

Right, that makes sense. I was trying to avoid having to make dynamic graphql strings with Apollo and I thought passing explicit null values would help with that.