0.9.1 • Published 4 months ago

@graphql-ez/plugin-schema v0.9.1

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

@graphql-ez/plugin-schema

Integration with @graphql-tools/schema

It can combine with other EZ Plugins like GraphQL Scalars and GraphQL Codegen.

Usage

registerTypeDefs and registerResolvers

You can use extra helpers that this plugin adds to your builder:

These helpers are specially useful when your API deals with a big amount of different type definitions and resolvers present in a lot of different directories, since you could simply call these functions, and you will only need to import them before calling buildApp(...), and this plugin will greatly simplify your code.

import { ezSchema } from '@graphql-ez/plugin-schema';

export const { registerTypeDefs, registerResolvers, buildApp, gql } = CreateApp({
  // ...
  ez: {
    plugins: [
      //...
      ezSchema(),
    ],
  },
});

// ...

registerTypeDefs(gql`
  type Query {
    hello: String!
  }
`);

registerResolvers({
  Query: {
    hello() {
      return 'Hello World!';
    },
  },
});

// ...

buildApp();

EZSchema

You can also define an EZSchema which has all the types to make an executable schema.

import { ezSchema, EZSchema, gql } from '@graphql-ez/plugin-schema';

const schema: EZSchema = {
  typeDefs: gql`
    type Query {
      hello: String!
    }
  `,
  resolvers: {
    Query: {
      hello(_root, _args, ctx) {
        return 'world';
      },
    },
  },
};

CreateApp({
  // ...
  ez: {
    plugins: [
      // ...
      ezSchema({
        schema,
      }),
    ],
  },
});

Multiple schemas

You can specify multiple schemas, and it will automatically merge the schemas.

CreateApp({
  // ...
  schema: [schema1, schema2, schema3],
});

You can customize the merging behavior following the documentation options

ezSchema({
  // ...
  schema: [schema1, schema2, schema3],

  // Check https://www.graphql-tools.com/docs/schema-merging
  mergeSchemasConfig: {
    // ...
  },
});
0.9.1

4 months ago

0.8.6

1 year ago

0.9.0

1 year ago

0.8.5

2 years ago

0.8.4

2 years ago

0.8.3

2 years ago

0.8.2

2 years ago

0.8.1

3 years ago

0.8.0

3 years ago

0.7.3

3 years ago

0.7.2

3 years ago

0.7.1

3 years ago

0.7.0

3 years ago

0.6.0

3 years ago

0.5.0

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago