Open ulevitsky opened 2 weeks ago
Hi @ulevitsky ,
Have you tried using mappers for this? Mappers is the recommended way to let resolvers return a different interface, to defer resolve to the other resolvers in the chain.
For you example, please add the following file:
// src/schema/zyblorb/schema.mappers.ts
export type ZyblorbMapper = {
id: number;
}
Running codegen will force create Zyblorb .flummles
:
// src/schema/flummle/resolvers/Zyblorb.ts
export type Zyblorb: Pick<ZyblorbResolvers, 'flummles'> = {
flummles: () => {
// your implementation here
}
}
Here's some resources related to using mappers:
Describe the bug Generated resolvers for module where the type originates require non-nullable extended fields to be defined there -- even though there's no mention of those fields in the originating module's schema, and the resolvers are duly defined in the extending module.
To Reproduce
src/schema/zyblorb/schema.graphql
:type Query { zyblorbs: [Zyblorb!]! }
type Flummle { id: Int! }
extend type Zyblorb { flummles: [Flummle!]! }
import type { CodegenConfig } from "@graphql-codegen/cli"; import { defineConfig } from "@eddeee888/gcg-typescript-resolver-files";
const config: CodegenConfig = { schema: "**/schema.graphql", generates: { "src/schema": defineConfig(), }, }; export default config;