@graphql-codegen/cli@7.4.4
Patch Changes
-
#11025
43d0f65
Thanks @BuddhaBing! - Widen
Types.SchemaWithLoaderOptions['loader']to accept a custom loader function
(CustomSchemaLoaderFn) in addition to a path string.A per-entry
schemacustom loader ({ '<pointer>': { loader, ...options } }) is resolved by
@graphql-tools/load'suseCustomLoader, which already accepts either a path string (resolved
viarequire()) or a function value at runtime (typeof loaderPointer === 'function'). Only the
TypeScript type restrictedloadertostring, forcing consumers who pass an imported loader
function (or a class instance exposing a boundloaderproperty) to cast theschemaarray to
bypass the type error, even though it worked correctly at runtime.This is additive and backward compatible —
loader: stringcontinues to type-check exactly as
before.Also fixes a schema-cache collision for function loaders in
@graphql-codegen/cli: the cache key
isJSON.stringify(schemaPointerMap), andJSON.stringifydrops functions, so twogenerates
targets using different loader functions for the same pointer
({ 'schema.graphql': { loader: fnA } }vs{ loader: fnB }) both keyed as
{"schema.graphql":{}}and the second silently reused the first's schema. Function values are now
keyed by object identity (via the existinggetJsObjectId), so distinct loaders load separately
while one function reused across targets still loads once. -
#11020
82ebbb5
Thanks @eddeee888! - Fix type errors incliunder
strict: true:@graphql-codegen/cli:loadCodegenConfigreturnsPromise<LoadCodegenConfigResult | null>,
matching thenullit resolves to when no config file is found.YamlCliFlagsincludes the
kebab-caseignore-no-documents,emit-legacy-common-js-importsandimport-extensionflags
that the CLI reads.CodegenContext.filepathis optional, and watch mode only watches the
config file when the context has afilepath.CodegenContext.getConfig()without an argument
returnsTypes.Config, andgetConfig(extraConfig)returnsT & Types.Config.
CodegenContext.checkModeStaleFilesis typed asstring[]. Adds@types/yargs,
@types/babel__generatorand@types/babel__templateas dev dependencies.@graphql-codegen/plugin-helpers:normalizeInstanceOrArrayandnormalizeConfigaccept
nullandundefined, returning[].
Generated output is unchanged.
-
Updated dependencies
[43d0f65,
82ebbb5,
e972b6d,
eae0e62,
1f7566f]:- @graphql-codegen/plugin-helpers@7.4.1
- @graphql-codegen/client-preset@6.2.1
@graphql-codegen/time@7.1.1
Patch Changes
- #11015
7088be0
Thanks @dependabot! - dependencies updates:- Updated dependency
moment@~2.31.0↗︎ (from
~2.30.0, independencies)
- Updated dependency
- Updated dependencies
[43d0f65,
82ebbb5,
eae0e62,
1f7566f]:- @graphql-codegen/plugin-helpers@7.4.1
@graphql-codegen/visitor-plugin-common@7.2.8
Patch Changes
-
#11009
1f7566f
Thanks @eddeee888! - Fix type errors intypescript-operations
understrict: trueby widening the shared types it calls into:@graphql-codegen/plugin-helpers:Types.ComplexPluginOutput'sprependandappendnow
acceptnullitems. Core already skipped them.@graphql-codegen/visitor-plugin-common:DeclarationBlock.withCommentacceptsundefined,
parseEnumValues'smapOrStris optional (it already defaulted to{}),
ImportSource.namespaceacceptsnull, andoptimizeOperations'sincludeFragmentsis
optional.@graphql-codegen/typescript-operations: skips document files without adocument, and no
longer throws when called without the plugin info argument.
Generated output is unchanged.
-
#11014
7a376ef
Thanks @eddeee888! - Fix type errors intypescriptunder
strict: trueby typing the shared visitor methods it overrides:@graphql-codegen/visitor-plugin-common: addsNormalizedDeclarationKindConfig(every
declaration kind set), used bynormalizeDeclarationKind,DEFAULT_DECLARATION_KINDSand
ParsedTypesConfig.declarationKind.BaseTypesVisitor'sNamedType,ListType,
FieldDefinition,InputValueDefinitionandUnionTypeDefinitionhave typed visitor params
(keyandparentare required, since the visitor always passes them), and
ObjectTypeDefinition,EnumTypeDefinitionandDirectiveDefinitionmay returnnull.@graphql-codegen/typescript: skips document files without adocumentwhen collecting
introspection types, types theTsVisitorvisitor params, andTsVisitor.EnumTypeDefinition
may returnnulllike the introspection visitor's override.
Generated output is unchanged.
-
#11031
3caccd3
Thanks @eddeee888! - Fix type errors invisitor-plugin-common
(selection-set-to-object,client-side-base-visitorandbase-documents-visitor) under
strict: true:BaseDocumentsVisitor._selectionSetToObjectis optional, since it is only set by
setSelectionSetHandler.FragmentDefinitionandOperationDefinitionthrow a descriptive
error when it is not set, andFragmentDefinitionthrows one when the fragment's type condition
is not in the schema.BaseDocumentsVisitor.FragmentDefinitionmay returnnull, which it already returns when
generateOperationTypesisfalse.ClientSideBaseVisitor.buildOperationmay returnnull, which its base implementation already
returns.SelectionSetToObject.transformSelectionSetdeclares its return type, and throws a descriptive
error when the instance has no selection set.LinkField'saliasis optional, matching the link fields built for fields without an alias.BaseSelectionSetProcessor.typeCacheis keyed byLocation | undefined, since selection sets
parsed withnoLocationhave noloc.getPossibleTypesaccepts anyGraphQLTypeorundefined, which it already handles by
unwrapping lists and non-nulls and returning no types, and returns a copy of the schema's
possible types instead of the schema's own readonly array.OperationVariablesToObject.transformacceptsundefined, which it already handles by
returningnull.
Generated output is unchanged.
-
#11030
ccc0d5c
Thanks @eddeee888! - Fix type errors invisitor-plugin-common
(base-resolvers-visitor) understrict: true:BaseResolversVisitor's constructor takesadditionalConfigasPartial<TPluginConfig>, since
the visitor fills in the defaults for every key it leaves out.BaseResolversVisitor'sScalarTypeDefinition,DirectiveDefinitionandEnumTypeDefinition
may returnnull, which they already return for skipped federation scalars and directives and
for enums withoutmappersorenumValues.BaseResolversVisitor.getAbstractMembersType'sisTypenameNonOptionalis optional, matching
the optionalresolversNonOptionalTypenameflags it is read from.BaseResolversVisitor.defaultMapperTypethrows a descriptive error when thedefaultMapper
config is not set.
Generated output is unchanged.
-
Updated dependencies
[43d0f65,
82ebbb5,
eae0e62,
1f7566f]:- @graphql-codegen/plugin-helpers@7.4.1
@graphql-codegen/typescript-operations@6.1.10
Patch Changes
-
#11019
eae0e62
Thanks @eddeee888! - Fix type errors inplugin-helpersunder
strict: true:@graphql-codegen/plugin-helpers:ProfilerEvent.catis optional, matching the Trace Event
format andProfiler.run's optionalcat.FederationMeta's reference selection sets are
typed recursively ({ [field: string]: true | ReferenceSelectionSet }), matching the nested
selections@key/@requires/@providesproduce.oldVisit'svisitorparam is typed as
OldVisitor:enterandleavemaps keyed by AST node kind, whose callbacks receive the typed
node plus graphql'skey,parent,pathandancestors. Federation directives missing their
fieldsargument, and operations whose root type is missing from the schema, throw a
descriptive error.@graphql-codegen/typescriptand@graphql-codegen/typescript-operations: the
InputValueDefinitionvisitor methods takepathandancestorsas required params, since the
visitor always passes them.
Generated output is unchanged.
-
#11009
1f7566f
Thanks @eddeee888! - Fix type errors intypescript-operations
understrict: trueby widening the shared types it calls into:@graphql-codegen/plugin-helpers:Types.ComplexPluginOutput'sprependandappendnow
acceptnullitems. Core already skipped them.@graphql-codegen/visitor-plugin-common:DeclarationBlock.withCommentacceptsundefined,
parseEnumValues'smapOrStris optional (it already defaulted to{}),
ImportSource.namespaceacceptsnull, andoptimizeOperations'sincludeFragmentsis
optional.@graphql-codegen/typescript-operations: skips document files without adocument, and no
longer throws when called without the plugin info argument.
Generated output is unchanged.
-
Updated dependencies
[43d0f65,
82ebbb5,
eae0e62,
1f7566f,
7a376ef,
3caccd3,
ccc0d5c]:- @graphql-codegen/plugin-helpers@7.4.1
- @graphql-codegen/visitor-plugin-common@7.2.8
@graphql-codegen/typescript@6.1.1
Patch Changes
-
#11019
eae0e62
Thanks @eddeee888! - Fix type errors inplugin-helpersunder
strict: true:@graphql-codegen/plugin-helpers:ProfilerEvent.catis optional, matching the Trace Event
format andProfiler.run's optionalcat.FederationMeta's reference selection sets are
typed recursively ({ [field: string]: true | ReferenceSelectionSet }), matching the nested
selections@key/@requires/@providesproduce.oldVisit'svisitorparam is typed as
OldVisitor:enterandleavemaps keyed by AST node kind, whose callbacks receive the typed
node plus graphql'skey,parent,pathandancestors. Federation directives missing their
fieldsargument, and operations whose root type is missing from the schema, throw a
descriptive error.@graphql-codegen/typescriptand@graphql-codegen/typescript-operations: the
InputValueDefinitionvisitor methods takepathandancestorsas required params, since the
visitor always passes them.
Generated output is unchanged.
-
#11014
7a376ef
Thanks @eddeee888! - Fix type errors intypescriptunder
strict: trueby typing the shared visitor methods it overrides:@graphql-codegen/visitor-plugin-common: addsNormalizedDeclarationKindConfig(every
declaration kind set), used bynormalizeDeclarationKind,DEFAULT_DECLARATION_KINDSand
ParsedTypesConfig.declarationKind.BaseTypesVisitor'sNamedType,ListType,
FieldDefinition,InputValueDefinitionandUnionTypeDefinitionhave typed visitor params
(keyandparentare required, since the visitor always passes them), and
ObjectTypeDefinition,EnumTypeDefinitionandDirectiveDefinitionmay returnnull.@graphql-codegen/typescript: skips document files without adocumentwhen collecting
introspection types, types theTsVisitorvisitor params, andTsVisitor.EnumTypeDefinition
may returnnulllike the introspection visitor's override.
Generated output is unchanged.
-
Updated dependencies
[43d0f65,
82ebbb5,
eae0e62,
1f7566f,
7a376ef,
3caccd3,
ccc0d5c]:- @graphql-codegen/plugin-helpers@7.4.1
- @graphql-codegen/visitor-plugin-common@7.2.8
@graphql-codegen/client-preset@6.2.1
Patch Changes
-
#10995
e972b6d
Thanks @eddeee888! - Fix type errors understrict: true. The
preset now throws a clear error whenschemaAstis missing from the preset options, and the babel
plugin throws when a file has no filename. Both cases used to crash later with a less clear error.
Generated output is unchanged. -
Updated dependencies
[43d0f65,
82ebbb5,
eae0e62,
1f7566f,
7a376ef,
3caccd3,
ccc0d5c]:- @graphql-codegen/plugin-helpers@7.4.1
- @graphql-codegen/typescript@6.1.1
- @graphql-codegen/typescript-operations@6.1.10
- @graphql-codegen/visitor-plugin-common@7.2.8
@graphql-codegen/plugin-helpers@7.4.1
Patch Changes
-
#11025
43d0f65
Thanks @BuddhaBing! - Widen
Types.SchemaWithLoaderOptions['loader']to accept a custom loader function
(CustomSchemaLoaderFn) in addition to a path string.A per-entry
schemacustom loader ({ '<pointer>': { loader, ...options } }) is resolved by
@graphql-tools/load'suseCustomLoader, which already accepts either a path string (resolved
viarequire()) or a function value at runtime (typeof loaderPointer === 'function'). Only the
TypeScript type restrictedloadertostring, forcing consumers who pass an imported loader
function (or a class instance exposing a boundloaderproperty) to cast theschemaarray to
bypass the type error, even though it worked correctly at runtime.This is additive and backward compatible —
loader: stringcontinues to type-check exactly as
before.Also fixes a schema-cache collision for function loaders in
@graphql-codegen/cli: the cache key
isJSON.stringify(schemaPointerMap), andJSON.stringifydrops functions, so twogenerates
targets using different loader functions for the same pointer
({ 'schema.graphql': { loader: fnA } }vs{ loader: fnB }) both keyed as
{"schema.graphql":{}}and the second silently reused the first's schema. Function values are now
keyed by object identity (via the existinggetJsObjectId), so distinct loaders load separately
while one function reused across targets still loads once. -
#11020
82ebbb5
Thanks @eddeee888! - Fix type errors incliunder
strict: true:@graphql-codegen/cli:loadCodegenConfigreturnsPromise<LoadCodegenConfigResult | null>,
matching thenullit resolves to when no config file is found.YamlCliFlagsincludes the
kebab-caseignore-no-documents,emit-legacy-common-js-importsandimport-extensionflags
that the CLI reads.CodegenContext.filepathis optional, and watch mode only watches the
config file when the context has afilepath.CodegenContext.getConfig()without an argument
returnsTypes.Config, andgetConfig(extraConfig)returnsT & Types.Config.
CodegenContext.checkModeStaleFilesis typed asstring[]. Adds@types/yargs,
@types/babel__generatorand@types/babel__templateas dev dependencies.@graphql-codegen/plugin-helpers:normalizeInstanceOrArrayandnormalizeConfigaccept
nullandundefined, returning[].
Generated output is unchanged.
-
#11019
eae0e62
Thanks @eddeee888! - Fix type errors inplugin-helpersunder
strict: true:@graphql-codegen/plugin-helpers:ProfilerEvent.catis optional, matching the Trace Event
format andProfiler.run's optionalcat.FederationMeta's reference selection sets are
typed recursively ({ [field: string]: true | ReferenceSelectionSet }), matching the nested
selections@key/@requires/@providesproduce.oldVisit'svisitorparam is typed as
OldVisitor:enterandleavemaps keyed by AST node kind, whose callbacks receive the typed
node plus graphql'skey,parent,pathandancestors. Federation directives missing their
fieldsargument, and operations whose root type is missing from the schema, throw a
descriptive error.@graphql-codegen/typescriptand@graphql-codegen/typescript-operations: the
InputValueDefinitionvisitor methods takepathandancestorsas required params, since the
visitor always passes them.
Generated output is unchanged.
-
#11009
1f7566f
Thanks @eddeee888! - Fix type errors intypescript-operations
understrict: trueby widening the shared types it calls into:@graphql-codegen/plugin-helpers:Types.ComplexPluginOutput'sprependandappendnow
acceptnullitems. Core already skipped them.@graphql-codegen/visitor-plugin-common:DeclarationBlock.withCommentacceptsundefined,
parseEnumValues'smapOrStris optional (it already defaulted to{}),
ImportSource.namespaceacceptsnull, andoptimizeOperations'sincludeFragmentsis
optional.@graphql-codegen/typescript-operations: skips document files without adocument, and no
longer throws when called without the plugin info argument.
Generated output is unchanged.