DEV Community

John Ding
John Ding

Posted on • Edited on

Strapi V4 Custom graphQL Resolver

https://www.theitsolutions.io/blog/how-to-add-custom-graphql-query-to-strapi-v4

https://forum.strapi.io/t/graphql-custom-resolver-in-v4/13506

Are GraphQL queries supposed to trigger controller actions in Strapi v4?

GraphQL custom resolver in V4

https://strapi.io/blog/extending-and-building-custom-resolvers-with-strapi-v4

register({ strapi }) {
    const extensionService = strapi.plugin('graphql').service('extension');

    const extension = ({}) => ({
      typeDefs: `
        type YourType {
          customResolver: [OtherType!]!
        }
      `,
      resolvers: {
        YourType: {
          customResolver: async (parent, args) => {
            const entries = await strapi.entityService.findMany('api::other-type.other-type', {});
            return entries;
          }
        }
      }
    })
Enter fullscreen mode Exit fullscreen mode

Top comments (0)