Open laytong opened 1 month ago
Update:
I think what i'm looking for is an option to explicit not auto generate certain keys in the interface because I know i'm using the parent resolver
Related issue also,
For graphs using federation, if I declare a type as defined in another subgraph i.e.
i.e. @key(fields: 'id', resolvable: false)
This preset still generates the resolvers, even though we actually don't want them.
Hi @laytong ,
Apologies, I couldn't get to this earlier.
At the moment i have to rewrite the logic in the child resolver every time.
I think this is the way implementing type resolvers work. In my observations, interfaces don't have field-level resolvers that like types. I believe the generated types may generate resolver types for interfaces which is could be wrong. Let me confirm with the codegen team
For graphs using federation, if I declare a type as defined in another subgraph i.e. i.e. @key(fields: 'id', resolvable: false) This preset still generates the resolvers, even though we actually don't want them.
Good news this bug is fixed in latest version v0.11. Could you please update and try again?
Hey, thanks for getting around to this.
Good news this bug is fixed in latest version v0.11. Could you please update and try again?
Awesome i'll check this out.
I think this is the way implementing type resolvers work.
Could be an implementation specific detail? perhaps apollo server specific? I know that if i delete generated child resolver it correctly uses the parent's method. but when there's a child resolver declared it uses that instead (which is the behaviour you'd want)
The frustration for me is that if everytime I regenerate my file, these child resolvers will keep coming back
perhaps this can be resolved with a directive? @inherits
or something?
So I have the following definition in my schema file as a field on another type
type User @key(fields: "userId", resolvable: false) @tag(name: "internal") {
userId: ID!
}
it still generates the resolver entry on the new version
import type { UserResolvers } from "./../../types.generated.js";
export const User: UserResolvers = {
/* Implement User resolver logic here */
};
Hi @laytong , I think if I have a reproducible repo, it would help me understand the issue better. To be honest, Federation support is a bit patchy at the moment, which is something I'm aiming to improve in the upcoming versions 🙂
When I have a series of types that implement a parent interface. I only want the field resolver to generate for the parent by default.
i.e.
when I generate the resolvers. I want to have a top level resolver for say
sound
defined onAnimal
but i get empty resolvers generated forCat
andDog
and if i delete them they will just be regenerated everytime I regen for new changes.Am i missing an existing setting or feature to handle this?
this would be exclusive to
interface
andimplements
relationshipsDescribe alternatives you've considered At the moment i have to rewrite the logic in the child resolver every time.
Additional context I am also making use of Mappers if that has any impact?