Skip to content

Utility that wrap GraphQL compose to high order functional pattern

License

Notifications You must be signed in to change notification settings

digithun/graphql-compose-recompose

Repository files navigation

Caution working process...

GraphQL Compose Recompose

This library help your life easier by create composing function that workwith GraphQL compose

Also with Typescript

Inspire by React utility lib Recompose

Installation

  $ npm install graphql-compose graphql graphql-compose-recompose

Example

From

UserTC.addFields({
  friend: {
    type: GraphQLString,
    resolve: () => 'Alan' 
  }
});
UserTC.extendField('friend',{
  description: 'Get his friend'
});

exports.TC = UserTC

To

const { compose, addRelation } = require('graphql-compose-recompose');
exports.TC = compose(
    addFields(
    'friends',{
      type: GraphQLString,
      resolve: () => 'Alan' 
    })
    extendField(
    'friend',{
      description: 'Get his friend'
    })
)(UserTC);

API

Typecomposer

  compose(
    setFields({
      foobar: {
      type: GraphQLString
      }
    }),
    addFields({
      foo: {
        type: GraphQLString
      }     
    }),
    // and more
    // removeField
    // removeOtherFields
    // reorderFields
    // deprecateFields
    // extendField
    // addResolver
    // removeResolver
    // setTypeName
    // setDescription
  )(type)

TODO

  • Wraping Typecomposer api
  • Wraping InputTypecomposer api
  • Wraping Resolver api
  • Add real life example
  • Unit test
  • Type definition
  • Use Commitizen
  • Add CI Build
  • Coverage