UNPKG

2.27 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var graphql_1 = require("graphql");
4var resolve_arguments_1 = require("./resolve-arguments");
5function transformDirectives(schema, directives) {
6 return directives.map(function (directive) {
7 var args = resolve_arguments_1.resolveArguments(schema, directive.args);
8 var locations = directive.locations || [];
9 return {
10 name: directive.name,
11 description: directive.description || '',
12 hasArguments: args.length > 0,
13 arguments: args,
14 locations: locations,
15 onFragmentSpread: locations.includes(graphql_1.DirectiveLocation.FRAGMENT_SPREAD),
16 onInlineFragment: locations.includes(graphql_1.DirectiveLocation.INLINE_FRAGMENT),
17 onQuery: locations.includes(graphql_1.DirectiveLocation.QUERY),
18 onMutation: locations.includes(graphql_1.DirectiveLocation.MUTATION),
19 onSubscription: locations.includes(graphql_1.DirectiveLocation.SUBSCRIPTION),
20 onFragment: locations.includes(graphql_1.DirectiveLocation.FRAGMENT_SPREAD),
21 onField: locations.includes(graphql_1.DirectiveLocation.FIELD),
22 onSchema: locations.includes(graphql_1.DirectiveLocation.SCHEMA),
23 onScalar: locations.includes(graphql_1.DirectiveLocation.SCALAR),
24 onFieldDefinition: locations.includes(graphql_1.DirectiveLocation.FIELD_DEFINITION),
25 onEnum: locations.includes(graphql_1.DirectiveLocation.ENUM),
26 onEnumValue: locations.includes(graphql_1.DirectiveLocation.ENUM_VALUE),
27 onObject: locations.includes(graphql_1.DirectiveLocation.OBJECT),
28 onInputObject: locations.includes(graphql_1.DirectiveLocation.INPUT_OBJECT),
29 onInputField: locations.includes(graphql_1.DirectiveLocation.INPUT_FIELD_DEFINITION),
30 onArgument: locations.includes(graphql_1.DirectiveLocation.ARGUMENT_DEFINITION),
31 onInterface: locations.includes(graphql_1.DirectiveLocation.INTERFACE),
32 onUnion: locations.includes(graphql_1.DirectiveLocation.UNION)
33 };
34 });
35}
36exports.transformDirectives = transformDirectives;
37//# sourceMappingURL=transform-directives.js.map
\No newline at end of file