graphile-build
Advanced tools
Comparing version 5.0.0-0.27 to 5.0.0-0.28
# graphile-build | ||
## 5.0.0-0.28 | ||
### Patch Changes | ||
- [#233](https://github.com/benjie/postgraphile-private/pull/233) | ||
[`a50bc5be4`](https://github.com/benjie/postgraphile-private/commit/a50bc5be4b4be344203f4acd0ffd5ad8b90d89b8) | ||
Thanks [@benjie](https://github.com/benjie)! - Introduce new | ||
GraphQLObjectType_fields_field_args_arg and | ||
GraphQLInterfaceType_fields_field_args_arg hooks to resolve some plugin | ||
ordering issues. | ||
- [#233](https://github.com/benjie/postgraphile-private/pull/233) | ||
[`6fb7ef449`](https://github.com/benjie/postgraphile-private/commit/6fb7ef4494b4f61b3b1aa36642e51eb9ec99a941) | ||
Thanks [@benjie](https://github.com/benjie)! - Also trim the empty | ||
descriptions from interface fields/args in addition to all the existing places | ||
empty descriptions are trimmed. | ||
- [#233](https://github.com/benjie/postgraphile-private/pull/233) | ||
[`11e7c12c5`](https://github.com/benjie/postgraphile-private/commit/11e7c12c5a3545ee24b5e39392fbec190aa1cf85) | ||
Thanks [@benjie](https://github.com/benjie)! - Solve mutation issue in plugin | ||
ordering code which lead to heisenbugs. | ||
- Updated dependencies | ||
[[`11e7c12c5`](https://github.com/benjie/postgraphile-private/commit/11e7c12c5a3545ee24b5e39392fbec190aa1cf85)]: | ||
- graphile-config@0.0.1-0.6 | ||
- grafast@0.0.1-0.22 | ||
## 5.0.0-0.27 | ||
@@ -4,0 +31,0 @@ |
@@ -1,3 +0,3 @@ | ||
import type { BaseGraphQLArguments, ExecutableStep, GraphileFieldConfig, GraphileFieldConfigArgumentMap, GraphileInputFieldConfig, GraphileInputFieldConfigMap, OutputPlanForType } from "grafast"; | ||
import type { GraphQLEnumType, GraphQLEnumTypeConfig, GraphQLEnumValueConfig, GraphQLEnumValueConfigMap, GraphQLFieldConfig, GraphQLFieldConfigArgumentMap, GraphQLFieldConfigMap, GraphQLInputFieldConfigMap, GraphQLInputObjectType, GraphQLInputObjectTypeConfig, GraphQLInputType, GraphQLInterfaceType, GraphQLInterfaceTypeConfig, GraphQLNamedType, GraphQLNonNull, GraphQLObjectType, GraphQLObjectTypeConfig, GraphQLOutputType, GraphQLScalarType, GraphQLScalarTypeConfig, GraphQLSchema, GraphQLSchemaConfig, GraphQLType, GraphQLUnionType, GraphQLUnionTypeConfig } from "graphql"; | ||
import type { BaseGraphQLArguments, ExecutableStep, GraphileArgumentConfig, GraphileFieldConfig, GraphileFieldConfigArgumentMap, GraphileInputFieldConfig, GraphileInputFieldConfigMap, OutputPlanForType } from "grafast"; | ||
import type { GraphQLArgumentConfig, GraphQLEnumType, GraphQLEnumTypeConfig, GraphQLEnumValueConfig, GraphQLEnumValueConfigMap, GraphQLFieldConfig, GraphQLFieldConfigArgumentMap, GraphQLFieldConfigMap, GraphQLInputFieldConfigMap, GraphQLInputObjectType, GraphQLInputObjectTypeConfig, GraphQLInputType, GraphQLInterfaceType, GraphQLInterfaceTypeConfig, GraphQLNamedType, GraphQLNonNull, GraphQLObjectType, GraphQLObjectTypeConfig, GraphQLOutputType, GraphQLScalarType, GraphQLScalarTypeConfig, GraphQLSchema, GraphQLSchemaConfig, GraphQLType, GraphQLUnionType, GraphQLUnionTypeConfig } from "graphql"; | ||
import type { Behavior } from "./behavior.js"; | ||
@@ -375,2 +375,8 @@ import type { InflectionBase } from "./inflection.js"; | ||
} | ||
interface ScopeObjectFieldsFieldArgsArg extends ScopeObjectFieldsFieldArgs { | ||
argName: string; | ||
} | ||
interface ContextObjectFieldsFieldArgsArg extends ContextObjectFieldsFieldArgs { | ||
scope: ScopeObjectFieldsFieldArgsArg; | ||
} | ||
interface ScopeInterface extends Scope { | ||
@@ -400,2 +406,8 @@ } | ||
} | ||
interface ScopeInterfaceFieldsFieldArgsArg extends ScopeInterfaceFieldsFieldArgs { | ||
argName: string; | ||
} | ||
interface ContextInterfaceFieldsFieldArgsArg extends ContextInterfaceFieldsFieldArgs { | ||
scope: ScopeInterfaceFieldsFieldArgsArg; | ||
} | ||
interface ScopeInterfaceInterfaces extends ScopeInterface { | ||
@@ -534,2 +546,3 @@ } | ||
GraphQLObjectType_fields_field_args: GraphileBuild.Hook<GraphileFieldConfigArgumentMap<any, any, any, any>, GraphileBuild.ContextObjectFieldsFieldArgs, TBuild>[]; | ||
GraphQLObjectType_fields_field_args_arg: GraphileBuild.Hook<GraphileArgumentConfig<any, any, any, any, any, any>, GraphileBuild.ContextObjectFieldsFieldArgsArg, TBuild>[]; | ||
/** | ||
@@ -579,2 +592,3 @@ * When creating a GraphQLInputObjectType via `newWithHooks`, we'll | ||
GraphQLInterfaceType_fields_field_args: GraphileBuild.Hook<GraphQLFieldConfigArgumentMap, GraphileBuild.ContextInterfaceFieldsFieldArgs, TBuild>[]; | ||
GraphQLInterfaceType_fields_field_args_arg: GraphileBuild.Hook<GraphQLArgumentConfig, GraphileBuild.ContextInterfaceFieldsFieldArgsArg, TBuild>[]; | ||
GraphQLInterfaceType_interfaces: GraphileBuild.Hook<GraphQLInterfaceType[], GraphileBuild.ContextInterfaceInterfaces, TBuild>[]; | ||
@@ -581,0 +595,0 @@ /** |
@@ -1,4 +0,4 @@ | ||
import type { GraphileFieldConfig, GraphileFieldConfigArgumentMap, PromiseOrDirect } from "grafast"; | ||
import type { GraphileArgumentConfig, GraphileFieldConfig, GraphileFieldConfigArgumentMap, PromiseOrDirect } from "grafast"; | ||
import type { AsyncHooks, PluginHook } from "graphile-config"; | ||
import type { GraphQLEnumTypeConfig, GraphQLEnumValueConfig, GraphQLEnumValueConfigMap, GraphQLFieldConfig, GraphQLFieldConfigArgumentMap, GraphQLFieldConfigMap, GraphQLInputFieldConfig, GraphQLInputFieldConfigMap, GraphQLInterfaceType, GraphQLNamedType, GraphQLObjectType, GraphQLScalarTypeConfig, GraphQLSchema, GraphQLSchemaConfig } from "graphql"; | ||
import type { GraphQLArgumentConfig, GraphQLEnumTypeConfig, GraphQLEnumValueConfig, GraphQLEnumValueConfigMap, GraphQLFieldConfig, GraphQLFieldConfigArgumentMap, GraphQLFieldConfigMap, GraphQLInputFieldConfig, GraphQLInputFieldConfigMap, GraphQLInterfaceType, GraphQLNamedType, GraphQLObjectType, GraphQLScalarTypeConfig, GraphQLSchema, GraphQLSchemaConfig } from "graphql"; | ||
/** | ||
@@ -183,3 +183,4 @@ * The details in the 'info' object passed as the first argument to all gather | ||
* - 'GraphQLObjectType_fields_field' to customize an individual field from above | ||
* - 'GraphQLObjectType_fields_field_args' to customize the arguments to a field | ||
* - 'GraphQLObjectType_fields_field_args' to add additional arguments to a field | ||
* - 'GraphQLObjectType_fields_field_args_arg' to customize an individual argument from above | ||
*/ | ||
@@ -191,2 +192,3 @@ GraphQLObjectType?: PluginHook<GraphileBuild.Hook<GraphileBuild.GraphileObjectTypeConfig<any, any>, GraphileBuild.ContextObject, GraphileBuild.Build>>; | ||
GraphQLObjectType_fields_field_args?: PluginHook<GraphileBuild.Hook<GraphileFieldConfigArgumentMap<any, any, any, any>, GraphileBuild.ContextObjectFieldsFieldArgs, GraphileBuild.Build>>; | ||
GraphQLObjectType_fields_field_args_arg?: PluginHook<GraphileBuild.Hook<GraphileArgumentConfig<any, any, any, any, any, any>, GraphileBuild.ContextObjectFieldsFieldArgsArg, GraphileBuild.Build>>; | ||
/** | ||
@@ -230,3 +232,4 @@ * When creating a GraphQLInputObjectType via `newWithHooks`, we'll | ||
* - 'GraphQLInterfaceType_fields_field' to customise an individual field from above | ||
* - 'GraphQLInterfaceType_fields_field_args' to customize the arguments to a field | ||
* - 'GraphQLInterfaceType_fields_field_args' to add additional arguments to a field | ||
* - 'GraphQLInterfaceType_fields_field_args_arg' to customize an individual arguments from the above | ||
*/ | ||
@@ -237,2 +240,3 @@ GraphQLInterfaceType?: PluginHook<GraphileBuild.Hook<GraphileBuild.GraphileInterfaceTypeConfig<any, any>, GraphileBuild.ContextInterface, GraphileBuild.Build>>; | ||
GraphQLInterfaceType_fields_field_args?: PluginHook<GraphileBuild.Hook<GraphQLFieldConfigArgumentMap, GraphileBuild.ContextInterfaceFieldsFieldArgs, GraphileBuild.Build>>; | ||
GraphQLInterfaceType_fields_field_args_arg?: PluginHook<GraphileBuild.Hook<GraphQLArgumentConfig, GraphileBuild.ContextInterfaceFieldsFieldArgsArg, GraphileBuild.Build>>; | ||
GraphQLInterfaceType_interfaces?: PluginHook<GraphileBuild.Hook<GraphQLInterfaceType[], GraphileBuild.ContextInterfaceInterfaces, GraphileBuild.Build>>; | ||
@@ -239,0 +243,0 @@ /** |
@@ -104,3 +104,3 @@ "use strict"; | ||
...resolvedFieldSpec, | ||
args: builder.applyHooks("GraphQLObjectType_fields_field_args", resolvedFieldSpec.args, build, argsContext, `|${Self.name}.fields.${fieldName}`), | ||
args: builder.applyHooks("GraphQLObjectType_fields_field_args", resolvedFieldSpec.args, build, argsContext, `|${Self.name}.fields.${fieldName}.args`), | ||
}; | ||
@@ -111,2 +111,10 @@ for (const [argName, argSpec] of Object.entries(finalFieldSpec.args)) { | ||
} | ||
const argContext = { | ||
...argsContext, | ||
scope: { | ||
...argsContext.scope, | ||
argName, | ||
}, | ||
}; | ||
finalFieldSpec.args[argName] = builder.applyHooks("GraphQLObjectType_fields_field_args_arg", argSpec, build, argContext, `|${Self.name}.fields.${fieldName}.args.${argName}`); | ||
} | ||
@@ -189,7 +197,20 @@ processedFields.push(finalFieldSpec); | ||
...newSpec, | ||
args: builder.applyHooks("GraphQLInterfaceType_fields_field_args", newSpec.args, build, argsContext, `|${Self.name}.fields.${fieldName}`), | ||
args: builder.applyHooks("GraphQLInterfaceType_fields_field_args", newSpec.args ?? Object.create(null), build, argsContext, `|${Self.name}.fields.${fieldName}.args`), | ||
}; | ||
const finalSpec = newSpec; | ||
processedFields.push(finalSpec); | ||
return finalSpec; | ||
const finalFieldSpec = newSpec; | ||
for (const [argName, argSpec] of Object.entries(finalFieldSpec.args)) { | ||
if (!argName) { | ||
throw new Error(`Attempted to add empty/falsy argName to GraphQLInterfaceType ${Self.name}'s '${fieldName}' field; ${(0, util_1.inspect)(argSpec)}`); | ||
} | ||
const argContext = { | ||
...argsContext, | ||
scope: { | ||
...argsContext.scope, | ||
argName, | ||
}, | ||
}; | ||
finalFieldSpec.args[argName] = builder.applyHooks("GraphQLInterfaceType_fields_field_args_arg", argSpec, build, argContext, `|${Self.name}.fields.${fieldName}.args.${argName}`); | ||
} | ||
processedFields.push(finalFieldSpec); | ||
return finalFieldSpec; | ||
}, | ||
@@ -196,0 +217,0 @@ }; |
@@ -51,17 +51,14 @@ "use strict"; | ||
}, | ||
GraphQLObjectType_fields_field_args: { | ||
callback: (args, build, context) => { | ||
GraphQLObjectType_fields_field_args_arg: { | ||
callback: (arg, build, context) => { | ||
const { extend } = build; | ||
const { scope: { isRootMutation, fieldName }, Self, } = context; | ||
const { scope: { isRootMutation, fieldName, argName }, Self, } = context; | ||
if (isRootMutation !== true || | ||
args.input == null || | ||
args.input.description != null) { | ||
return args; | ||
argName !== "input" || | ||
arg.description != null) { | ||
return arg; | ||
} | ||
return { | ||
...args, | ||
input: extend(args.input, { | ||
description: "The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields.", | ||
}, `Adding a description to input arg for field '${fieldName}' field in '${Self.name}'`), | ||
}; | ||
return extend(arg, { | ||
description: "The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields.", | ||
}, `Adding a description to input arg for field '${fieldName}' field in '${Self.name}'`); | ||
}, | ||
@@ -68,0 +65,0 @@ provides: ["ClientMutationIdDescription"], |
@@ -33,13 +33,7 @@ "use strict"; | ||
*/ | ||
function rmEmptyArgDescriptions(args) { | ||
if (!args) { | ||
return args; | ||
function rmEmptyArgDescriptions(arg) { | ||
if (arg.description === "") { | ||
arg.description = null; | ||
} | ||
for (const argName in args) { | ||
const arg = args[argName]; | ||
if (arg.description === "") { | ||
arg.description = null; | ||
} | ||
} | ||
return args; | ||
return arg; | ||
} | ||
@@ -54,3 +48,3 @@ exports.TrimEmptyDescriptionsPlugin = { | ||
GraphQLObjectType_fields_field: rmEmptyFieldDescription, | ||
GraphQLObjectType_fields_field_args: rmEmptyArgDescriptions, | ||
GraphQLObjectType_fields_field_args_arg: rmEmptyArgDescriptions, | ||
GraphQLInputObjectType: rmEmptyTypeDescription, | ||
@@ -60,2 +54,4 @@ GraphQLInputObjectType_fields_field: rmEmptyFieldDescription, | ||
GraphQLInterfaceType: rmEmptyTypeDescription, | ||
GraphQLInterfaceType_fields_field: rmEmptyFieldDescription, | ||
GraphQLInterfaceType_fields_field_args_arg: rmEmptyArgDescriptions, | ||
GraphQLEnumType: rmEmptyTypeDescription, | ||
@@ -62,0 +58,0 @@ }, |
@@ -21,2 +21,3 @@ "use strict"; | ||
GraphQLObjectType_fields_field_args: [], | ||
GraphQLObjectType_fields_field_args_arg: [], | ||
GraphQLInputObjectType: [], | ||
@@ -34,2 +35,3 @@ GraphQLInputObjectType_fields: [], | ||
GraphQLInterfaceType_fields_field_args: [], | ||
GraphQLInterfaceType_fields_field_args_arg: [], | ||
GraphQLInterfaceType_interfaces: [], | ||
@@ -36,0 +38,0 @@ GraphQLScalarType: [], |
@@ -35,3 +35,3 @@ import type { GraphQLNamedType, GraphQLScalarTypeConfig } from "graphql"; | ||
*/ | ||
export declare const stringScalarSpec: Readonly<Omit<GraphQLScalarTypeConfig<unknown, unknown>, "name" | "description">>; | ||
export declare const stringScalarSpec: Readonly<Omit<GraphQLScalarTypeConfig<unknown, unknown>, "description" | "name">>; | ||
/** | ||
@@ -38,0 +38,0 @@ * Only use this on descriptions that are plain text, or that we create |
{ | ||
"name": "graphile-build", | ||
"version": "5.0.0-0.27", | ||
"version": "5.0.0-0.28", | ||
"description": "Build a GraphQL schema from plugins", | ||
@@ -44,4 +44,4 @@ "type": "commonjs", | ||
"debug": "^4.3.3", | ||
"grafast": "^0.0.1-0.21", | ||
"graphile-config": "^0.0.1-0.5", | ||
"grafast": "^0.0.1-0.22", | ||
"graphile-config": "^0.0.1-0.6", | ||
"graphile-export": "^0.0.2-0.4", | ||
@@ -48,0 +48,0 @@ "lodash": "^4.17.21", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
379526
4610
Updatedgrafast@^0.0.1-0.22
Updatedgraphile-config@^0.0.1-0.6