Open arie-finaloop opened 2 months ago
Happens in 6.3.3.
type schema
interface Foo { id: ID! fooType: String! .... createdAt: Date! updatedAt: Date! deletedAt: Date publishedAt: Date ... } type Bar implements Foo @key(fields: "id") { .... } type Baz implements Foo @key(fields: "id") { .... }
query
extend type Query { ... getFoos(input: GetFoosInput!): GetFoosResult! ... } type GetFoosResult { foos: [Foo!]! }
type resolvers
export const typeResolvers: Resolvers = { Foo: { __resolveType: (_parent, _context) => { return 'Bar'; }, }, };
typescript function with bad return type
export const getFoosByIds = async (params: GetFoosByIds) => { const data = await gqlClient.query({ getFoos: { __args: { input: { ... }, }, foos: { id: true, __typename: true, }, }, }); return data.getFoos.foos[0]; }
the returning type has all fields and not only id and __typename
id
__typename
GEN-33 inferred type from a query fetching specific fields from an interface returns a type with all fields instead
looks like there is a similar issue when Foo is a union of Bar and Baz (where Bar and Baz are concrete types that share the fields of the foo "interface")
Happens in 6.3.3.
type schema
query
type resolvers
typescript function with bad return type
the returning type has all fields and not only
id
and__typename