{"action":"closed","issue":{"url":"https://api.github.com/repos/taion/graphql-type-json/issues/15","repository_url":"https://api.github.com/repos/taion/graphql-type-json","labels_url":"https://api.github.com/repos/taion/graphql-type-json/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/taion/graphql-type-json/issues/15/comments","events_url":"https://api.github.com/repos/taion/graphql-type-json/issues/15/events","html_url":"https://github.com/taion/graphql-type-json/issues/15","id":208574197,"number":15,"title":"Can't get GraphQL to recognize the JSON scalar type.","user":{"login":"g-lsh","id":22301790,"avatar_url":"https://avatars.githubusercontent.com/u/22301790?v=3","gravatar_id":"","url":"https://api.github.com/users/g-lsh","html_url":"https://github.com/g-lsh","followers_url":"https://api.github.com/users/g-lsh/followers","following_url":"https://api.github.com/users/g-lsh/following{/other_user}","gists_url":"https://api.github.com/users/g-lsh/gists{/gist_id}","starred_url":"https://api.github.com/users/g-lsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/g-lsh/subscriptions","organizations_url":"https://api.github.com/users/g-lsh/orgs","repos_url":"https://api.github.com/users/g-lsh/repos","events_url":"https://api.github.com/users/g-lsh/events{/privacy}","received_events_url":"https://api.github.com/users/g-lsh/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-02-17T22:24:42Z","updated_at":"2017-02-17T22:48:30Z","closed_at":"2017-02-17T22:48:30Z","body":"Hi, I can't get GraphQL to recognize the JSON scalar type.\r\n\r\nI followed the [apollo docs] (http://dev.apollodata.com/tools/graphql-tools/scalars.html#Using-a-package)  to define a JSON GraphQL scalar type for my schema:\r\n\r\n```javascript\r\n\r\nSchema:\r\n\r\n    const SchemaDefinition = `\r\n       scalar JSON\r\n       schema {\r\n         query: Query\r\n         mutation: Mutation\r\n      }\r\n    `\r\n\r\n    export default [\r\n      SchemaDefinition,\r\n      Query,\r\n      Mutation,\r\n      ...\r\n    ]\r\n```\r\nTest type:\r\n```javascript\r\n    const Test = `\r\n      type Test {\r\n        bodyJson: JSON\r\n     }`\r\n```\r\n\r\nResolver:\r\n  \r\n```javascript\r\n\r\n    import GraphQLJSON from 'graphql-type-json'\r\n\r\n    const QueryResolver = {\r\n      Query: {\r\n        viewer(root, args, ctx) {\r\n          return User.query()\r\n            .where('id', ctx.state.user)\r\n            .first()\r\n         }\r\n      }\r\n    }\r\n\r\n    const scalarJSON = {\r\n      JSON: GraphQLJSON\r\n    }\r\n\r\n    export default {\r\n      ...QueryResolver,\r\n      ...ViewerResolver,\r\n      ...scalarJSON\r\n      ...\r\n    }\r\n\r\n```\r\n\r\nI'm using PostgreSQL and the column I'm querying (body_json) is of data type jsonb.\r\n\r\nIf I test my schema through GraphiQL, when I return the value straight from the db (I use Knex to query) I get this error message from GraphQL:\r\n\r\n`Expected a value of type \\\"JSON\\\" but received: [object Object]`\r\n\r\nIf I use JSON.stringify first on the returned value, I get this error:\r\n\r\n`\"Expected a value of type \\\"JSON\\\" but received: {\\\"key\\\":\\\"test\\\"}\"`\r\n\r\nAny suggestion as to what I might be doing wrong?"}}
{"actor":{"display_login":"taion"}}