Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using graphql-iso-date and custom scalars #38

Open
vonazt opened this issue Oct 7, 2019 · 1 comment
Open

Using graphql-iso-date and custom scalars #38

vonazt opened this issue Oct 7, 2019 · 1 comment

Comments

@vonazt
Copy link

vonazt commented Oct 7, 2019

I've been trying to use the graphql-iso-date package with graphql-s2s for DateTime formatting on types and get this error:
TypeError: Cannot read property 'directive' of null

Is this a known issue, or is there a workaround? My typeDefs file looks like this:

export const commonTypeDefs = `
scalar DateTime

type Timestamps {
  created: DateTime
  started: DateTime
  modified: DateTime
  completed: DateTime
}`

resolvers:

import { GraphQLDateTime } from "graphql-iso-date"

export const resolvers = {
  DateTime: GraphQLDateTime,
  Query: {
   ...
    }

and my index merging:

import { makeExecutableSchema } from 'graphql-tools'
import commonTypeDefs from './commonTypeDefs'
const { transpileSchema } = require('graphql-s2s').graphqls2s

import typeDefs from './typeDefs.gql'
import { resolvers } from './resolvers'

export const workSchema = makeExecutableSchema({
  typeDefs: [transpileSchema(commonTypeDefs), typeDefs],
  resolvers
})
@vonazt vonazt changed the title Using graphqql-iso-date and custom scalars Using graphql-iso-date and custom scalars Oct 7, 2019
@vonazt
Copy link
Author

vonazt commented Oct 7, 2019

seems to have been fixed by changing the export type in commonTypeDefs:

export default `
scalar DateTime

type Timestamps {
  created: DateTime
  started: DateTime
  modified: DateTime
  completed: DateTime
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant