-
It's not a problem with GiraphQL and the code works as expected. Strict mode was disabled and this error was not showing up (thankfully now it's enabled, I've missed the docs on this). I had to type I have a forum which has children and its type is forum (self relation). Here's the code and the error: import { Forum } from '@prisma/client'
import builder from 'builder'
import db from 'utils/prisma'
const ForumObject = builder.objectRef<Forum>('Forum').implement({ //ERROR: 'ForumObject' implicitly
//has type 'any' because it does not have a type annotation
//and is referenced directly or indirectly in its own initializer.
fields: (t) => ({
...
children: t.field({
type: [ForumObject], // << referencing its own
nullable: true,
resolve: async (parent) => await db.forum.findUnique({ where: { id: parent.id } }).children(),
}),
... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Just split up the ref and implement into 2 statements.
|
Beta Was this translation helpful? Give feedback.
Just split up the ref and implement into 2 statements.