Describe the bug
The mapper field is omitted first then added back force required in resolvers.
To Reproduce
Steps to reproduce the behavior:
type Author {
name: ID!
addr: String
}
type Post {
authorID: ID!
author: Author
}
type Query {
posts: [Post!]!
}
schema {
query: Query
}
N/A
codegen.yml config file:overwrite: true
schema: introspection-schema.js
generates:
src/graphql/types.ts:
config:
mappers:
Author: "@/models/Author#AuthorDocument"
plugins:
- add: '/* tslint:disable */'
- typescript
- typescript-resolvers
Expected behavior
The generated types:
/** Mapping between all available schema types and the resolvers types */
export type ResolversTypes = {
Query: Query;
Post: Omit<Post, 'author'> & { author: Maybe<ResolversTypes['Author']> };
ID: Scalars['ID'];
Author: AuthorDocument;
String: Scalars['String'];
Boolean: Scalars['Boolean'];
};
The author in Post should be optional.
Environment:
@graphql-codegen/...: v1.0.7 Additional context
I found this bug, because the author is field-resolved based on authorID in my case.
Hi! I think I'm also having the same issue... but I also think that it is related to #1531 .. it seems that the solution is to use fragments to match exactly the desired type... though I don't like it... I like the way of v0.18 of manage this kind of scenarios... :(
@enzonotario Your issue it not related to @flisky (it's an issue with typescript-resolvers).
@enzonotario Please refer to this thread: https://github.com/dotansimha/graphql-code-generator/issues/1602 , we added typescript-compatibility plugin that should cover that.
Fixed in 1.1.1 馃帀