Closed s-r-jones closed 5 years ago
It is possible with
DateTime(obj, args, context, field) {
if (obj[field.fieldName]) return obj[field.fieldName]
return new Date('2019-01-01')
},
@dmtrKovalenko Thanks for your help. Where would I put this code? Like mockgraphqlOptions({mocks: DateTimeResolver })
For anyone hitting finding this issue and finding it a bit confusing on where to add the scalar type resolver, it can be defined in the mockGraphql()
config under mocks
cy.mockGraphql({
...
mocks: {
DateTime: () => new Date()
}
})
I am importing my schema as one big json object and seeing this error when I try to run the command.
GraphQL error: No mock defined for type "DateTime"
To reproduce, add the custom DateTime scalar as a type to one of your properties.