Using asNexusMethod for datetime / json (graphql types)
See original GitHub issueI am trying to implement the types for date(time)/json as suggested in the docs (https://nexusjs.org/docs/api/scalar-type) but for my case they or at least type checking doesn`t seem to work.
I have a single shared.ts file with the following code:
import { interfaceType } from '@nexus/schema'
import { asNexusMethod } from '@nexus/schema'
import { DateTimeResolver, JSONObjectResolver } from 'graphql-scalars'
export const jsonScalar = asNexusMethod(JSONObjectResolver, 'json')
export const dateTimeScalar = asNexusMethod(DateTimeResolver, 'date')
export const SoftDelte = interfaceType({
name: 'SoftDelete',
definition(t) {
t.date('createdAt') // VSCode reports that "date" is unknown
t.date('updatedAt') // VSCode reports that "date" is unknown
t.date('deletedAt') // VSCode reports that "date" is unknown
t.resolveType(() => null)
},
})
This is my package.json:
{ "name": "test", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "dev": "ts-node-dev --transpile-only --no-notify api/app.ts", "build": "tsc" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "@nexus/schema": "^0.16.0", "@prisma/client": "^2.9.0", "apollo-server": "^2.18.2", "apollo-server-express": "^2.18.2", "express": "^4.17.1", "graphql": "^15.3.0", "graphql-scalars": "^1.4.0", "nexus-plugin-prisma": "^0.21.0" }, "devDependencies": { "@prisma/cli": "^2.9.0", "ts-node-dev": "^1.0.0-pre.65", "typescript": "^4.0.3" } }
I am running npm run dev
while in the code window.
Please help!
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Hey everyone, I don’t think anyone is being rude here, all good. Let’s relax and keep a welcoming atmosphere 😃
Thanks @Sytten looks like some good doc content here indeed.
@TommyCoding About your problems with
json
typing, if you can share a repo repro with us that would help a lot.I believe this is fixed in 0.19+