2.0.1 • Published 5 years ago

@grapheng/time v2.0.1

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

Moar Types

A library of custom GraphQL types.

Install

TODO: Make a real package on npmjs.

For now...

npm pack this lib up.

npm install --save ../wherever/moar-types-1.0.0.tgz

Use

There are 2 main ways of getting these types in your project.

  1. Import ALL typeDefs and resolvers:
import * as MoarTypes from 'moar-types'

const mySchema = makeExecutableSchema({
	typeDefs: gql`
		${MoarTypes.typeDefs}
		${myApplicationTypeDefs}
	`,
	resolvers: {
		...MoarTypes.resolvers,
		...myApplicationResolvers
	}
})
  1. Import individual typeDefs and resolvers:
import { FormattedDuration } from 'moar-types'

const mySchema = makeExecutableSchema({
	typeDefs: gql`
		${FormattedDuration.typeDefs}
		${myApplicationTypeDefs}
	`,
	resolvers: {
		FormattedDuration: FormattedDuration.resolvers,
		...myApplicationResolvers
	}
})

Or if you don't use SDL+Resolvers

import { FormattedDate } from 'moar-types'

const mySchema = new GraphQLSchema({
	query: new GraphQLObjectType({
		name: 'Query',
		fields: {
			twoHoursAgo: {
				type: new GraphQLNonNull(FormattedDate.FormattedDate),
				resolve: () => getTwoHoursAgo()
			}
		}
	})
})