Graphql - how to create support for field level access


We have a collection of projects. When project status is “done” should we be able to get all info = all fields. In any other case we shouldn’t have access to field “result”

Is this possible?

Not sure I fully understand the question, can you describe a bit more?

The need is to be able to control what is returned depending on a status which is just one of the fields.

Here is a perhaps better example with project. When active you get all details, when archived you only can only get a few

When active:

  projectname: "learning strapi",
  status: "ACTIVE",
  description: "this description is only returned when status is "ACTIVE",

When inactive:

  projectname: "learning strapi",
  status: "INACTIVE",
  description: null,

Makes better sense?

Yup that makes more sense, in this case when it’s swapped back to active do you want the same description to be shown again or do you want to set a new one?

(I’m asking as this could be achieved via the lifecycle callbacks and just setting the desc to null)

Ah - good idea for another thing but not in this case. Data is preserved - its just what is being allowed in the response

That will be slightly more complicated, I know it will need to have a customized resolver but I need to test some options.

1 Like

Is it possible to add a field level resolver?

Hi All. Just wanne ask if anyone has ever done something like this in Strapi and what did it take?

I’m thinking that it could be a general requirement to to hide information when it’s in a certain state?