Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@grapheng/time

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@grapheng/time

Time types for GraphQL

latest
npmnpm
Version
2.0.1
Version published
Maintainers
2
Created
Source

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()
			}
		}
	})
})

FAQs

Package last updated on 30 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts