Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia committed Nov 7, 2021
1 parent 30b4469 commit 2255959
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/type/directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import type { DirectiveDefinitionNode } from '../language/ast';
import { DirectiveLocation } from '../language/directiveLocation';

import type {
GraphQLArgument,
GraphQLFieldConfigArgumentMap,
GraphQLArgument, GraphQLEnumValue, GraphQLField,
GraphQLFieldConfigArgumentMap, GraphQLInputField, GraphQLType,
} from './definition';
import { assertName } from './assertName';
import { GraphQLString, GraphQLBoolean } from './scalars';
Expand Down Expand Up @@ -109,6 +109,8 @@ export class GraphQLDirective {
}
}

type DirectiveExposeArgs = (definition: GraphQLType|GraphQLField<unknown, unknown>|GraphQLEnumValue|GraphQLInputField|GraphQLArgument) => Record<string, string>

export interface GraphQLDirectiveConfig {
name: string;
description?: Maybe<string>;
Expand All @@ -117,6 +119,7 @@ export interface GraphQLDirectiveConfig {
isRepeatable?: Maybe<boolean>;
extensions?: Maybe<Readonly<GraphQLDirectiveExtensions>>;
astNode?: Maybe<DirectiveDefinitionNode>;
exposeArgs?: Maybe<DirectiveExposeArgs>
}

interface GraphQLDirectiveNormalizedConfig extends GraphQLDirectiveConfig {
Expand Down Expand Up @@ -191,6 +194,15 @@ export const GraphQLDeprecatedDirective: GraphQLDirective =
defaultValue: DEFAULT_DEPRECATION_REASON,
},
},
exposeArgs: (definition: GraphQLField<unknown, unknown>|GraphQLInputField|GraphQLEnumValue) => {
if (definition.deprecationReason != null) {
return [
definition.deprecationReason === DEFAULT_DEPRECATION_REASON
? {}
: { reason: definition.deprecationReason },
];
}
}
});

/**
Expand Down

0 comments on commit 2255959

Please sign in to comment.