Sascha
09/03/2020, 2:56 PMSascha
09/03/2020, 2:57 PMscalar Json
actually shows up in my Nexus generated schema, I assume there's a better way?Ryan
09/03/2020, 3:16 PMfield: arg({ type: 'Json' })
Sascha
09/03/2020, 3:27 PMMajdi Toumi
10/21/2020, 7:43 PMRyan
10/22/2020, 5:40 AMargs
option like this:
t.field('someField', {
type: 'ModelType',
args: {
field: arg({ type: 'Json' }),
},
async resolve(_root, args, ctx) {
// resolver
},
})
If the Json
scalar is not present in your schema.graphql
then you can add it as follows:
const Json = scalarType({
name: 'Json',
asNexusMethod: 'json',
description: 'Json custom scalar type',
parseValue(value) {
return JSON.stringify(value)
},
serialize(value) {
return JSON.parse(value)
},
})