I want to return my result as a JSON OBJECT in the metas field on the graphiql interface, and how can I define a custom scalar for JSON OBJECT if JSON OBJECT can not be defined.
I have tried GraphQLJSON from graphql-type-json as an npm package but when I use it, it throws an error message that field type must be an output type
const PostType = new GraphQLObjectType({
name : "Post",
fields : () => ({
id : { type: GraphQLInt },
title : { type: GraphQLString },
slug : { type: GraphQLString },
content : { type: GraphQLString },
type : { type: GraphQLString },
template : { type: GraphQLString },
link : { type: GraphQLString },
doctor_id : { type: GraphQLInt },
categories : { type: GraphQLString },
publishdate: {type: GraphQLDate},
metas: {type: GraphQLJSON }
})
})
const mutation = new GraphQLObjectType({
name: 'Mutation',
fields: {
/********* Post */
createPost: {
type: schemaObjects.PostType,
args: {
title: { type: GraphQLString },
slug: { type: GraphQLString },
content: { type: GraphQLString },
type: { type: GraphQLString },
status: { type: GraphQLString },
template: { type: GraphQLString },
categories: { type: GraphQLString },
doctor_id: { type: GraphQLInt },
link: { type: GraphQLString },
publishdate: { type: GraphQLDate},
metas: {type:GraphQLJSON }
,
resolve(parentValue, args) {
let post = PostController.create(args);
return post;
}
},
GraphQLJSON? - Daniel Reardenconst { GraphQLJSON } = require('graphql-type-json')- Daniel Rearden