Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Handling graphql requests that include items the user can no longer access

default discord avatar
devperson2 years ago
4

In our platform we have a favourites collection that's a many to many relationship between content items and users, however there are scenarios whereby users could favourite a content post and then subsequently not have access to that content item, meaning we get the following error when querying via gql



Cannot return null for non-nullable field Favourite.content

I am wondering whether there is a good way of handing this? Ideally without modifying the favourites table, as they could regain access to that content in the future



Anyone have any ideas on this?



Not been able to figure this one out yet, anyone got any ideas?

  • default discord avatar
    jessrynkar2 years ago

    hi

    @932901256136114206

    - can you update

    favourite.content

    to be a nullable field? can you show where you are defining the schema?



    Also, this page is helpful:

    https://graphql.wtf/episodes/42-graphql-nullability
  • default discord avatar
    devperson2 years ago

    It was a graphql schema generated by payload, is there a way to mark a field as nullable?

  • default discord avatar
    jessrynkar2 years ago

    Sorry for the delay - do you still need help here

    @932901256136114206

    ?

  • default discord avatar
    devpersonlast year

    not urgently, we worked around this by making a custom graphql endpoint rather than the default payload generated endpoint to handle this

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.