Hi Timo,
I found the same thing right after I installed the first V4 beta, since then I’ve been asking but still didn’t get an answer.
Truth is that there is no documentation or examples on customizing graphQL in v4.
Check the discussion under this Github issue that sheds some first light on gql customization:
opened 11:29AM - 01 Dec 21 UTC
issue-type: feature request
source: plugin:graphql
<!--
Hello 👋 Thank you for submitting a feature request.
We are using Produc… tBoard to manage our roadmap and feature requests.
Can you please submit your feature request here: https://portal.productboard.com/strapi
-->
## Feature request
in V3 you had this feature
https://docs-v3.strapi.io/developer-docs/latest/development/plugins/graphql.html#aggregation-grouping
is this no longer possible in v4? do you have alternative?
### Why is it needed?
I have a project that uses this functionality and would like to migrate in on v4 in the future.
My last comment shows how to resolve gql query using a controller - but I still don’t know how to correctly format the data (when returned the response seems empty). Maybe you will find an answer to this (if you do, please let me know).
Another github issue to watch would be this request for documentation on gql customization:
opened 11:38AM - 01 Dec 21 UTC
type: doc request
### Summary
in backend-customization/
https://docs.strapi.io/developer-doc… s/latest/development/backend-customization/controllers.html#adding-a-new-controller
you have this example:
```js
// path: ./src/api/restaurant/controllers/restaurant.js
const { createCoreController } = require('@strapi/strapi').factories;
module.exports = createCoreController('api::restaurant.restaurant', ({ strapi }) => ({
// Method 1: Creating an entirely custom action
async exampleAction(ctx) {
try {
ctx.body = 'ok';
} catch (err) {
ctx.body = err;
}
},
// Method 2: Wrapping a core action (leaves core logic in place)
async find(ctx) {
// some custom logic here
ctx.query = { ...ctx.query, local: 'en' }
// Calling the default core action
const { data, meta } = await super.find(ctx);
// some more custom logic
meta.date = Date.now()
return { data, meta };
},
// Method 3: Replacing a core action
async findOne(ctx) {
const { id } = ctx.params;
const { query } = ctx;
const entity = await strapi.service('api::restaurant.restaurant').findOne(id, query);
const sanitizedEntity = await this.sanitizeOutput(entity, ctx);
return this.transformResponse(sanitizedEntity);
}
});
```
how to can we do the same for GraphQL? both adding a new method (exampleAction) and extending existing ones like find and findMany
### Why is it needed?
I want to use GraphQL but can't figure it out, how to extend it.
in particular I'm interested in create a method to return an entity via slug with graphQL, whit a new custom method like getEntityBySlug(slug) that returns a single entity, and not using find(filters)
### Suggested solution(s)
_No response_
### Related issue(s)/PR(s)
_No response_