Gramps does not seem to support custom scalar types
grxy opened this issue · comments
I have created a data source to support a custom JSON scalar, based on this tutorial: https://www.apollographql.com/docs/graphql-tools/scalars.html
My data source is defined as follows:
import GraphQLJSON from 'graphql-type-json'
const resolvers = {
Query: {
json: () => JSON.stringify({ test: true })
},
JSON: GraphQLJSON,
}
const JSONDataSource = {
namespace: 'JSON',
context: {},
resolvers,
typeDefs: `
scalar JSON
type Query {
json: JSON
}
`
}
export default JSONDataSource
This causes the following issue in my build:
Error: Expected Function for name resolver but received string
at checkFn (/path/to/project/node_modules/@gramps/gramps/dist/lib/mapResolvers.js:13:11)
I think because we are mapping over all of the keys in mapResolvers, and not checking for built-in GraphQL types, there are some issues.
My proposed solution is that if we encounter any built-in GraphQL types that cause this issue (at least scalars, possibly enums), that we simply pass them in as-is to the final resolver map. Thoughts?
Closed by #42.
I just cut a new beta release, so yarn add @gramps/gramps@beta
will pull in this change.
Thank you @jlengstorf @ecwyne!
@jlengstorf Seems like 1.0.0-beta-8
does not have this fix. Can you possibly republish?
@grxy Republished. Sorry about that. Let me know if it's still missing; I see it in the package when I install it now.
@jlengstorf It's there. Thanks!