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

Custom scalar examples don't work #215

Closed
scf4 opened this issue Nov 29, 2016 · 3 comments
Closed

Custom scalar examples don't work #215

scf4 opened this issue Nov 29, 2016 · 3 comments

Comments

@scf4
Copy link

scf4 commented Nov 29, 2016

The examples http://dev.apollodata.com/tools/graphql-tools/scalars.html#Own-GraphQLScalarType-instance don't seem to work. Am I missing something?

e.g.,

import GraphQLJSON from 'graphql-type-json';

const resolvers = { ExampleCustomType: GraphQLJSON, ...etc };

export default makeExecutableSchema({ typeDefs, resolvers });

My resolver just returns false. I also tried creating my own types with new GraphQLScalarType({}) and got the same.

Then I find this with the following example:

Limit: {
    __description: '...',
    __parseValue(value) {
      return value;
    },
    __serialize(value) {
      return value;
    },
    __parseLiteral(ast) {
      ...
      return parsedLimit;
    },
  }

and const resolvers = { ExampleCustomType: Limit, ..etc } works.

I feel I must be missing something really obvious here?

@helfer
Copy link
Contributor

helfer commented Nov 29, 2016

@scf4 I think this was fixed in #203. If you update to 0.8.3 it should work. What version does npm list | grep grapqhl say you're on?

@scf4
Copy link
Author

scf4 commented Nov 29, 2016

Great! I was on 0.8.1. Thanks.

@helfer
Copy link
Contributor

helfer commented Nov 30, 2016

Ok, glad it works now!

@helfer helfer closed this as completed Nov 30, 2016
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

2 participants