22 BooleanValueNode ,
33 ConstDirectiveNode ,
44 ConstValueNode ,
5+ DefinitionNode ,
56 DirectiveDefinitionNode ,
67 EnumValueDefinitionNode ,
78 EnumValueNode ,
@@ -26,6 +27,7 @@ import {
2627 ExtensionType ,
2728 ExternalFieldData ,
2829 FieldData ,
30+ InputObjectDefinitionData ,
2931 InputValueData ,
3032 InterfaceDefinitionData ,
3133 NodeData ,
@@ -35,7 +37,7 @@ import {
3537 PersistedDirectivesData ,
3638 SchemaData ,
3739} from './types' ;
38- import { MutableFieldNode , MutableInputValueNode , MutableTypeDefinitionNode } from './ast' ;
40+ import { MutableDefinitionNode , MutableFieldNode , MutableInputValueNode } from './ast' ;
3941import { ObjectTypeNode , setToNameNodeArray , stringToNameNode } from '../ast/utils' ;
4042import {
4143 incompatibleInputValueDefaultValuesError ,
@@ -46,7 +48,6 @@ import { SubscriptionFilterValue } from '../router-configuration/types';
4648import {
4749 ARGUMENT ,
4850 AUTHENTICATED ,
49- AUTHORIZATION_DIRECTIVES ,
5051 BOOLEAN_SCALAR ,
5152 DEPRECATED ,
5253 DEPRECATED_DEFAULT_ARGUMENT_VALUE ,
@@ -58,7 +59,6 @@ import {
5859 INPUT_NODE_KINDS ,
5960 INT_SCALAR ,
6061 MUTATION ,
61- NON_REPEATABLE_PERSISTED_DIRECTIVES ,
6262 OUTPUT_NODE_KINDS ,
6363 PERSISTED_CLIENT_DIRECTIVES ,
6464 QUERY ,
@@ -69,7 +69,6 @@ import {
6969 SHAREABLE ,
7070 STRING_SCALAR ,
7171 SUBSCRIPTION ,
72- TAG ,
7372} from '../utils/string-constants' ;
7473import {
7574 generateRequiresScopesDirective ,
@@ -285,7 +284,7 @@ export function setParentDataExtensionType(existingData: ParentDefinitionData, i
285284 existingData . extensionType = ExtensionType . NONE ;
286285}
287286
288- function upsertDeprecatedDirective (
287+ export function upsertDeprecatedDirective (
289288 persistedDirectivesData : PersistedDirectivesData ,
290289 incomingDirectiveNode : ConstDirectiveNode ,
291290) {
@@ -299,7 +298,7 @@ function upsertDeprecatedDirective(
299298 }
300299}
301300
302- function upsertTagDirectives (
301+ export function upsertTagDirectives (
303302 persistedDirectivesData : PersistedDirectivesData ,
304303 incomingDirectiveNodes : ConstDirectiveNode [ ] ,
305304) {
@@ -310,42 +309,6 @@ function upsertTagDirectives(
310309 }
311310}
312311
313- export function extractPersistedDirectives (
314- persistedDirectivesData : PersistedDirectivesData ,
315- directivesByDirectiveName : Map < DirectiveName , ConstDirectiveNode [ ] > ,
316- persistedDirectiveDefinitionByDirectiveName : Map < DirectiveName , DirectiveDefinitionNode > ,
317- ) : PersistedDirectivesData {
318- for ( const [ directiveName , directiveNodes ] of directivesByDirectiveName ) {
319- // @authenticated and @requiresScopes are handled differently
320- if (
321- AUTHORIZATION_DIRECTIVES . has ( directiveName ) ||
322- ! persistedDirectiveDefinitionByDirectiveName . has ( directiveName )
323- ) {
324- continue ;
325- }
326- if ( directiveName === DEPRECATED ) {
327- persistedDirectivesData . isDeprecated = true ;
328- upsertDeprecatedDirective ( persistedDirectivesData , directiveNodes [ 0 ] ) ;
329- continue ;
330- }
331- if ( directiveName === TAG ) {
332- upsertTagDirectives ( persistedDirectivesData , directiveNodes ) ;
333- continue ;
334- }
335- const existingDirectives = persistedDirectivesData . directivesByDirectiveName . get ( directiveName ) ;
336- if ( ! existingDirectives ) {
337- persistedDirectivesData . directivesByDirectiveName . set ( directiveName , [ ...directiveNodes ] ) ;
338- continue ;
339- }
340- // Only add one instance of certain directives.
341- if ( NON_REPEATABLE_PERSISTED_DIRECTIVES . has ( directiveName ) ) {
342- continue ;
343- }
344- existingDirectives . push ( ...directiveNodes ) ;
345- }
346- return persistedDirectivesData ;
347- }
348-
349312export function propagateAuthDirectives ( parentData : ParentDefinitionData , authData ?: AuthorizationData ) {
350313 if ( ! authData ) {
351314 return ;
@@ -468,17 +431,6 @@ export function getClientPersistedDirectiveNodes<T extends NodeData>(nodeData: T
468431 return persistedDirectiveNodes ;
469432}
470433
471- export function getNodeForRouterSchemaByData < T extends ParentDefinitionData | EnumValueData > (
472- data : T ,
473- persistedDirectiveDefinitionByDirectiveName : Map < DirectiveName , DirectiveDefinitionNode > ,
474- errors : Error [ ] ,
475- ) : T [ 'node' ] {
476- data . node . name = stringToNameNode ( data . name ) ;
477- data . node . description = data . description ;
478- data . node . directives = getRouterPersistedDirectiveNodes ( data , persistedDirectiveDefinitionByDirectiveName , errors ) ;
479- return data . node ;
480- }
481-
482434export function getClientSchemaFieldNodeByFieldData ( fieldData : FieldData ) : MutableFieldNode {
483435 const directives = getClientPersistedDirectiveNodes ( fieldData ) ;
484436 const argumentNodes : MutableInputValueNode [ ] = [ ] ;
@@ -557,7 +509,7 @@ function addValidatedArgumentNodes(
557509}
558510
559511export function addValidPersistedDirectiveDefinitionNodeByData (
560- definitions : MutableTypeDefinitionNode [ ] ,
512+ definitions : ( MutableDefinitionNode | DefinitionNode ) [ ] ,
561513 data : PersistedDirectiveDefinitionData ,
562514 persistedDirectiveDefinitionByDirectiveName : Map < DirectiveName , DirectiveDefinitionNode > ,
563515 errors : Error [ ] ,
@@ -783,6 +735,10 @@ export function isFieldData(data: ChildData | NodeData | SchemaData): data is Fi
783735 return data . kind === Kind . FIELD_DEFINITION ;
784736}
785737
738+ export function isInputObjectDefinitionData ( data : ParentDefinitionData ) : data is InputObjectDefinitionData {
739+ return data . kind === Kind . INPUT_OBJECT_TYPE_DEFINITION ;
740+ }
741+
786742export function isInputNodeKind ( kind : Kind ) : kind is InputNodeKind {
787743 return INPUT_NODE_KINDS . has ( kind ) ;
788744}
0 commit comments