-
-
Notifications
You must be signed in to change notification settings - Fork 820
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
WIP - Let a user define a custom scalar type by passing a GraphQLScalarType through resolveFunctions #189
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oricordeau Thanks for the contribution, we are almost there.. :)
@@ -68,6 +68,11 @@ function addMockFunctionsToSchema({ schema, mocks = {}, preserveResolvers = fals | |||
defaultMockMap.set('String', () => 'Hello World'); | |||
defaultMockMap.set('Boolean', () => Math.random() > 0.5); | |||
defaultMockMap.set('ID', () => uuid.v4()); | |||
defaultMockMap.set('JSON', () => ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think it should be in here,
please define the mock specificly when you use JSON type.
those are the library's default mocks, and JSON is not a default type..
@@ -281,6 +281,14 @@ function addResolveFunctionsToSchema(schema: GraphQLSchema, resolveFunctions: IR | |||
return; | |||
} | |||
|
|||
if (typeName === 'JSON') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong as well,
you are not adding the ability to add any custom scalar type, but just the one named JSON.
the patch should just be able to merge any already existing GraphQLObject (Or just Scalar? - @helfer what do you think?) with the schema.
Thanks for your feedback ! Now processing it ... ;) |
For those who read, some informations about this PR are available in the corresponding issue : |
Yep, I agree that this PR should be structured allow people to use any GraphQL-JS scalar type, not just JSON. |
…through resolveFunctions
Hi, I just made a new commit and now it's supposed to be better ... Tell me. |
@oricordeau hi im on vacation with limited access. |
@DxCx Happy vacation, then :) |
This looks great! So what should we do with the documentation here: http://dev.apollodata.com/tools/graphql-tools/scalars.html I guess we should still document some but also document how to use packages like the JSON type? |
Well done @oricordeau ! |
Great !! I'll make a PR on the docs repo soon ... |
TODO: