@graphql-ez/plugin-modules
TypeScript icon, indicating that this package has built-in type declarations

0.12.1 • Public • Published

@graphql-ez/plugin-modules

Integration with GraphQL Modules

Usage

This plugin add an extra registerModule helper in your ezApp, which will automatically add the specified GraphQL Module in your GraphQL EZ Application, this plugin will take care of the rest.

This plugin works the best paired with the GraphQL Code Generator plugin with the option deepPartialResolvers enabled (already enabled by default)

import { ezGraphQLModules, gql } from '@graphql-ez/plugin-modules';

const ezApp = CreateApp({
  ez: {
    plugins: [
      ezGraphQLModules({
        // ApplicationConfig https://www.graphql-modules.com/docs/api#applicationconfig
      }),
      // ...
    ],
  },
  // ...
});

// ...

ezApp.registerModule(
  gql`
    type Query {
      hello: String!
    }
  `,
  {
    resolvers: {
      Query: {
        hello(_root, _args, _ctx) {
          return 'Hello World';
        },
      },
    },
  }
);

// ...

ezApp.registerModule(
  gql`
    extend type Query {
      bye: String!
    }
  `,
  {
    resolvers: {
      Query: {
        bye(_root, _args, _ctx) {
          return 'Bye World';
        },
      },
    },
  }
);

/@graphql-ez/plugin-modules/

    Package Sidebar

    Install

    npm i @graphql-ez/plugin-modules

    Weekly Downloads

    3

    Version

    0.12.1

    License

    MIT

    Unpacked Size

    11.2 kB

    Total Files

    6

    Last publish

    Collaborators

    • pablosz