Releases: ThreadsStyling/apollo-resolver-types
Releases · ThreadsStyling/apollo-resolver-types
v3.5.0
v3.4.1
v3.4.0
v3.3.0
v3.2.0
v3.1.0
v3.0.0
3.0.0 (2020-03-03)
Bug Fixes
BREAKING CHANGES
When upgrading TypeScript you will get an error. This is due to a breaking change in TypeScript which led to a naming collision (see Local and Imported Type Declarations Now Conflict)
Option 1
You will need to add typesPrefix: I
to the config:
section of your codegen.yml file and rename the import from GeneratedTypes.Resolvers
to GeneratedTypes.IResolvers
.
codegen.yml
schema: ./schema.graphql
overwrite: true
generates:
./__generated__/types.ts:
plugins:
- add:
placement: 'prepend'
content: |+
/* tslint:disable */
// This file was automatically generated and should not be edited.
import ResolverContext from '../ResolverContext';
- typescript
- typescript-resolvers
config:
federation: true
contextType: ResolverContext
+ typesPrefix: I
mappers:
User: ../types/nodes#User
Sale: ../types/nodes#Sale
ResolverTypes.ts
import ApolloResolverTypes from '@threads/apollo-resolver-types';
import * as GeneratedTypes from './__generated__/types';
- type ResolverTypes = ApolloResolverTypes<GeneratedTypes.Resolvers>;
+ type ResolverTypes = ApolloResolverTypes<GeneratedTypes.IResolvers>;
export default ResolverTypes;
Option 2
Alternatively you can just update the config:
schema: ./schema.graphql
overwrite: true
generates:
./__generated__/types.ts:
plugins:
- add:
placement: 'prepend'
content: |+
/* tslint:disable */
// This file was automatically generated and should not be edited.
import ResolverContext from '../ResolverContext';
- typescript
- typescript-resolvers
config:
federation: true
contextType: ResolverContext
mappers:
- User: ../types/nodes#User
+ User: ../types/nodes#User as DbUser
- Sale: ../types/nodes#Sale
+ Sale: ../types/nodes#Sale as DbSale
The point is to make sure that the two types don't conflict:
- The generated types for the objects returned from the GraphQL API and for user inputs (mainly used in tests)
- The types for the data returned from the database that are passed as the first parameter to resolvers
These two types cannot have the same names as each other.