1.0.4 • Published 2 years ago

graphql-aggregator v1.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Table of contents

What is this?

You can use plugins to define graphql resolvers like below

// This is src/utils/graphqlUtils.ts
import { resolverCreator } from 'graphql-aggregator/index';

import type {
  QueryResolvers,
  MutationResolvers,
} from "../../generated/graphql";
import { Context } from '@src/context';

export const
  defQuery = resolverCreator<QueryResolvers, Context>(),
  defMutation = resolverCreator<MutationResolvers, Context>()

Then define resolver and combine them.

import { combineResolvers } from "@src/utils/graphqlType";
import { defQuery} from '@src/utils/graphqlUtils.ts'

const combinedQueryResolver = combineResolvers([
    defMutation("greeting", {
    type: GStr,
    resolve: async (_, args, ctx) => "Hello world with graphql-aggregator!!",
  }),
]);

import { GraphQLObjectType, GraphQLSchema } from 'graphql';

const schema = new GraphQLSchema({
    query: new GraphQLObjectType({
        name: "Query",
        fields: queryResolvers
    })
});

When should I use this?

  • Who don't like ApolloGraphql, TypeGrapql
  • Who want to use origint graphql library
  • Who want to apply type system to resolve

If you apply above conditions, this package help you.

Getting started

npm install graphql-aggregator