@grapheng/time
v2.0.1
Published
Time types for GraphQL
Downloads
2
Readme
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.
- Import ALL typeDefs and resolvers:
import * as MoarTypes from 'moar-types'
const mySchema = makeExecutableSchema({
typeDefs: gql`
${MoarTypes.typeDefs}
${myApplicationTypeDefs}
`,
resolvers: {
...MoarTypes.resolvers,
...myApplicationResolvers
}
})
- 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()
}
}
})
})