Releases: dotansimha/graphql-code-generator-community
May 18, 2023
@graphql-codegen/[email protected]
Major Changes
- #335
b46fff0d6
Thanks @michaelgmcd! - feature: support graphql-request 6+
@graphql-codegen/[email protected]
Patch Changes
March 27, 2023
@graphql-codegen/[email protected]
Patch Changes
- #297
f73ab7114
Thanks @dargmuesli! - Accesses IntrospectionData via
CacheExchangeOpts's schema.
March 23, 2023
@graphql-codegen/[email protected]
Patch Changes
- #311
2c1652ec0
Thanks @domdomegg! - Limit graphql-request version in plugin to <=
5.1 to reflect breaking changes in graphql-request package.
February 14, 2023
@graphql-codegen/[email protected]
Minor Changes
- #70
e6e85a999
Thanks @aplr! - Make typescript-generic-sdk respect thedocumentMode
external option by prefixing types with the value configured inimportOperationTypesFrom
as documented.
@graphql-codegen/[email protected]
Patch Changes
-
#269
d28569b9a
Thanks @plmercereau! - Initial releaseThe
typescript-nhost
plugin generates the schema for theTypescript Nhost SDK
.What the plugin does:
- Generate types with
graphql-codegem/typescript
, following a strict configuration. (the plugin does not require@graphql-codegen/typescript
to be installed by the user but is use as a dependency). - Minify the introspection object with
'@urql/introspection
- Export the introspection object as well as all the types so they can be accessed through a default
import schema from './generated-schema'
Installation
yarn add -D @graphql-codegen/cli @graphql-codegen/typescript-nhost
Then configure the code generator by adding a
codegen.yaml
file:schema: - http://localhost:1337/v1/graphql: headers: x-hasura-admin-secret: nhost-admin-secret generates: ./src/schema.ts: plugins: - typescript-nhost
Usage
yarn add @nhost/nhost-js
import { NhostClient } from '@nhost/nhost-js'; import schema from './schema'; const nhost = new NhostClient({ subdomain: 'localhost', schema });
A GraphQL query named
todos
will then be accessible through:const todos = await nhost.graphql.query.todos({ select: { contents: true } });
The
todos
object will be strongly typed based on the GraphQL schema, and the fields that would have been selected in the query. - Generate types with
@graphql-codegen/[email protected]
Patch Changes
-
#248
98d3da6b1
Thanks @DominicGBauer! - fix: update imported api to use alternate namePreviously imported api name did not update actual implementation
import { newApiName } from '../baseApi' ... const injectedApi = oldApiName...
now it does update the implementation
import { newApiName } from '../baseApi' ... const injectedApi = newApiName... ...
February 01, 2023
@graphql-codegen/[email protected]
Patch Changes
- #72
c70b4ce49
Thanks @MitkoTschimev! - missing trailing comma in enums
BeforeNowenum AssetOrder { @JsonKey(name: 'contentType_ASC') contentTypeAsc @JsonKey(name: 'contentType_DESC') contentTypeDesc }
enum AssetOrder { @JsonKey(name: 'contentType_ASC') contentTypeAsc, @JsonKey(name: 'contentType_DESC') contentTypeDesc, }
@graphql-codegen/[email protected]
Minor Changes
-
#75
7e80265e9
Thanks @DominicGBauer! - [typescript-rtk-query] feat: add importAlternateApiName to conifg optionsAdd functionality to allow users to use the optional config variable importAlternateApiName to change the api name of the import used by baseApi. It will default to 'api'.
January 31, 2023
@graphql-codegen/[email protected]
Patch Changes
-
#74
349dc3a58
Thanks @Parables! - docs(plugin config): 📝 updated plugin-configadded @type decorators, added missing TypeName and FieldName variables in the exampleMarkdowns
Breaking: mergeTypes signature changed to mergeTypes?: Record<string, TypeName[]>
Even though the key is a string, we recommend that you use the value of a TypeName.Example:
import type { CodegenConfig } from '@graphql-codegen/cli'; const Movie = TypeName.fromString('Movie'); const CreateMovieInput = TypeName.fromString('CreateMovieInput'); const UpdateMovieInput = TypeName.fromString('UpdateMovieInput'); const UpsertMovieInput = TypeName.fromString('UpsertMovieInput'); const config: CodegenConfig = { generates: { 'lib/data/models/app_models.dart': { plugins: { 'flutter-freezed': { mergeTypes: { [Movie.value]: [CreateMovieInput, UpdateMovieInput, UpsertMovieInput], }, }, }, }, }, }; export default config;
@graphql-codegen/[email protected]
Minor Changes
January 22, 2023
@graphql-codegen/[email protected]
Major Changes
-
#47
f56200632
Thanks @Parables! - # Configuring the plugin using patternsWhat has changed
The following type definitions have been removed:
-
CustomDecorator = Record<string, DecoratorToFreezed>;
-
DecoratorToFreezed
- arguments?: string[];
- applyOn: ApplyDecoratorOn[];
- mapsToFreezedAs: '@default' | '@deprecated' | 'final' | 'directive' | 'custom';
-
FieldConfig
- final?: boolean;
- deprecated?: boolean;
- defaultValue?: any;
- customDecorators?: CustomDecorator;
-
FreezedConfig
- alwaysUseJsonKeyName?: boolean;
- copyWith?: boolean;
- customDecorators?: CustomDecorator;
- defaultUnionConstructor?: boolean;
- equal?: boolean;
- fromJsonToJson?: boolean;
- immutable?: boolean;
- makeCollectionsUnmodifiable?: boolean;
- mergeInputs?: string[];
- mutableInputs?: boolean;
- privateEmptyConstructor?: boolean;
- unionKey?: string;
- unionValueCase?: 'FreezedUnionCase.camel' | 'FreezedUnionCase.pascal';
-
TypeSpecificFreezedConfig
- deprecated?: boolean;
- config?: FreezedConfig;
- fields?: Record<string, FieldConfig>;
-
FlutterFreezedPluginConfig:
- fileName?: string;
- globalFreezedConfig?: FreezedConfig
- typeSpecificFreezedConfig?: Record<string, TypeSpecificFreezedConfig>;
Why those type definitions were removed
The previous version allow you to configure GraphQL Types and its fields globally using the
globalFreezedConfig
and override the global configuration with specific ones of each GraphQL Type using thetypeSpecificFreezedConfig
.This resulted in a bloated configuration file with duplicated configuration for the same options but for different cases.
To emphasize on the problem, consider the before and after configurations below:
Before:
{ globalFreezedConfig: { immutable: true, }, typeSpecificFreezedConfig: { Starship: { deprecated: true, }, Droid: { config: { immutable: false, }, fields: { id: { deprecated: true, }, }, }, }, };
After:
{ immutable: TypeNamePattern.forAllTypeNamesExcludeTypeNames([Droid]), deprecated: [ [TypeNamePattern.forTypeNames([Starship]), ['default_factory']], [FieldNamePattern.forFieldNamesOfTypeName([[Droid, id]]), ['default_factory_parameter']], ], }
The 2 configurations above do the same thing, the later being more compact, flexible and readable than the former.
How to update your existing configuration
First understand the usage of the Patterns, then create a new config file(preferably a typescript file: previous version of the code generator used a YAML file).
And implement the new configuration one by one inspecting the generated output.Please avoid migrating all your configuration at once. Doing that means you wont be able to inspect the generated output and ensure that the expected results are produced.
-
@graphql-codegen/[email protected]
Minor Changes
@graphql-codegen/[email protected]
Patch Changes
- #45
296ce64c0
Thanks @FloEdelmann! - Default to empty object foroptions
parameter in generated mutation functions, even those with required variables.
January 16, 2023
@graphql-codegen/[email protected]
Minor Changes
- #25
a70964409
Thanks @EandrewJones! - Reverts problematic part of PR #8497. That PR fixed an issue with infinite query generated hooks not utilizing pageParamKeys for custom fetchers but in the process introduced a type error. This removes the cause of the type error.
January 05, 2023
@graphql-codegen/[email protected]
Minor Changes
- #24
41b0ae176
Thanks @gwesseling! - Added the fileName option for the near-operation-file-preset to force the generated filename
November 24, 2022
@graphql-codegen/[email protected]
Patch Changes
- #21
8a0359623
Thanks @charlypoly! - doc API examples fix
@graphql-codegen/[email protected]
Patch Changes
- #19
d98ca30cd
Thanks @charlypoly! - Fix compatibility of graphql-request fetcher with >5.0