Is it possible to extend graphql plugin in strapi V4 to remove nested data and attributes fields?

I have been trying to extend graphql plugin to be able to remove the nested data and attributes. But after checking the internal code I’m not sure if the response by a function inside graphql plugin.
would you please help if this is something that can be extended? And if yes which function should I extend to be able to change the returned json object using graphql API.
I’m using strapi v4.

Thanks a lot!

I think it can be extended.

You can see the general flow here.

When making a query, we add a resolver to the content type’s definition, then calls the entity service and return the raw data which gets transformed into the needed format. The data then get passed to the graphql types (e.g. for the entity) and their resolvers to format the data into the id/attributes structure

The only possible way to accomplish what you are looking to do is with custom resolvers with custom types that will return the data in the format that you require.

Thank you to @Convly for the help answering this question.

1 Like