v0.13.0
Core
- Updated the documents validation rules (fixes #726)
- Document how to pass documents and how to pass generator config when using programmatic api (#656)
- Updated dependencies.
- Better errors (#760)
- Added cli spinner (#745)
- documents files are now exposed to the templates (#721)
TypeScript Template
BREAKING CHANGES
resolvers
feature move to a separate template, you can use it now asgraphql-codegen-typescript-resolvers-template
. Is also includes the base TypeScript template. You can just switch tographql-codegen-typescript-resolvers-template
to use it just like before.
(#742)
Bug Fixes
- Fixed incorrect output on a mixed usage of InlineFragment and FragmentSpread (#711)
- Fixed incorrect naming and conversions (#702, #701)
- Fixed comments location (#697)
- Added missing separator between InlineFragments and SpreadFragments (#695)
TypsScript Resolvers Templates
We moved the resolvers template to a separate template, and it includes all base template of typescript
.
New Features
- You can now specify custom mappings for your resolvers (#757)
- You can now set the generic type of the parent value (#756)
- You can now set your own type for
Context
(instead of overriding it each time) (#743)
Bug Fixes
- SubscriptionResolver is not used in Subscription-related fields (#727)
- Subscription resolver now supports NestJS (#698)
- Use
never
as arguments type when there are no arguments (#741)
NEW TEMPLATE!!! Generates TypeScript module
declaration for .graphql
files
This template generates TypeScript typings for .graphql
files containing GraphQL documents, and you can later consume it using graphql-tag/loader
, and get type-check and type-safty for your imports. That also means that now when you will import from .graphql
files, your IDE will provide auto-complete.
This template also handles .graphql
files containing multiple GraphQL documents, and name the imports according to the operation name.
For example, if you have a query called MyQuery
in my-query.graphql
, this template will generate the following code:
declare module '*/my-query.graphql' {
import { DocumentNode } from 'graphql';
const MyQuery: DocumentNode;
export { MyQuery };
export default defaultDocument;
}
Later, in your code, you can use default import, or named imports:
import myQuery from './my-query.graphql';
// OR
import { myQuery } from './my-query.graphql';
React-Apollo Template
Bug fixes:
- Exclude imports from graphql-codegen-typescript-react-apollo-template (#744)
- Template content is skipped now when there are no operations (#750)
- Fix fragment/document conflict in React template (#738)