Skip to content

Commit

Permalink
Add support for deprecating arguments to makeExtendSchemaPlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
benjie committed Feb 1, 2024
1 parent 941e280 commit e427272
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 8 additions & 1 deletion graphile-build/graphile-utils/src/makeExtendSchemaPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
EnumTypeDefinitionNode,
EnumValueDefinitionNode,
FieldDefinitionNode,
GraphQLArgumentConfig,
GraphQLDirective,
GraphQLEnumType,
// Config:
Expand Down Expand Up @@ -1001,11 +1002,17 @@ export function makeExtendSchemaPlugin(
if (arg.defaultValue) {
defaultValue = getValue(arg.defaultValue, type);
}
const argDirectives = getDirectives(arg.directives);
const deprecatedDirective = argDirectives.find(
(d) => d.directiveName === "deprecated",
);
const deprecationReason = deprecatedDirective?.args.reason;
memo[name] = {
type,
deprecationReason,
...(defaultValue != null ? { defaultValue } : null),
...(description ? { description } : null),
};
} as GraphQLArgumentConfig;
} else {
throw new Error(
`Unexpected '${arg.kind}', we were expecting an 'InputValueDefinition'`,
Expand Down
4 changes: 3 additions & 1 deletion postgraphile/postgraphile/graphile.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ const preset: GraphileConfig.Preset = {
return {
typeDefs: gql`
extend type Person {
greet(greeting: String! = "Hello"): String
greet(
greeting: String! = "Hello" @deprecated(reason: "TESTING")
): String
query: Query
}
`,
Expand Down

0 comments on commit e427272

Please sign in to comment.