@@ -77,20 +77,21 @@ class DirectiveWiringHelper(
77
77
private fun <T : GraphQLDirectiveContainer > wireDirectives (wrapper : WiringWrapper <T >): T {
78
78
val directivesContainer = wrapper.graphQlType.definition as DirectivesContainer <* >
79
79
val directives = buildDirectives(directivesContainer.directives, wrapper.directiveLocation)
80
+ val directivesByName = directives.associateBy { it.name }
80
81
var output = wrapper.graphQlType
81
82
// first the specific named directives
82
- directives. forEach { directive ->
83
- val env = buildEnvironment(wrapper, directives, directive )
84
- val wiring = runtimeWiring.registeredDirectiveWiring[directive .name]
83
+ wrapper.graphQlType.appliedDirectives. forEach { appliedDirective ->
84
+ val env = buildEnvironment(wrapper, directives, directivesByName[appliedDirective.name], appliedDirective )
85
+ val wiring = runtimeWiring.registeredDirectiveWiring[appliedDirective .name]
85
86
wiring?.let { output = wrapper.invoker(it, env) }
86
87
}
87
88
// now call any statically added to the runtime
88
89
runtimeWiring.directiveWiring.forEach { staticWiring ->
89
- val env = buildEnvironment(wrapper, directives, null )
90
+ val env = buildEnvironment(wrapper, directives, null , null )
90
91
output = wrapper.invoker(staticWiring, env)
91
92
}
92
93
// wiring factory is last (if present)
93
- val env = buildEnvironment(wrapper, directives, null )
94
+ val env = buildEnvironment(wrapper, directives, null , null )
94
95
if (runtimeWiring.wiringFactory.providesSchemaDirectiveWiring(env)) {
95
96
val factoryWiring = runtimeWiring.wiringFactory.getSchemaDirectiveWiring(env)
96
97
output = wrapper.invoker(factoryWiring, env)
@@ -131,7 +132,7 @@ class DirectiveWiringHelper(
131
132
return output
132
133
}
133
134
134
- private fun <T : GraphQLDirectiveContainer > buildEnvironment (wrapper : WiringWrapper <T >, directives : List <GraphQLDirective >, directive : GraphQLDirective ? ): SchemaDirectiveWiringEnvironmentImpl <T > {
135
+ private fun <T : GraphQLDirectiveContainer > buildEnvironment (wrapper : WiringWrapper <T >, directives : List <GraphQLDirective >, directive : GraphQLDirective ? , appliedDirective : GraphQLAppliedDirective ? ): SchemaDirectiveWiringEnvironmentImpl <T > {
135
136
val nodeParentTree = buildAstTree(* listOfNotNull(
136
137
wrapper.fieldsContainer?.definition,
137
138
wrapper.inputFieldsContainer?.definition,
@@ -154,7 +155,7 @@ class DirectiveWiringHelper(
154
155
is GraphQLFieldsContainer -> schemaDirectiveParameters.newParams(wrapper.graphQlType, nodeParentTree, elementParentTree)
155
156
else -> schemaDirectiveParameters.newParams(nodeParentTree, elementParentTree)
156
157
}
157
- return SchemaDirectiveWiringEnvironmentImpl (wrapper.graphQlType, directives, wrapper.graphQlType.appliedDirectives, directive, params)
158
+ return SchemaDirectiveWiringEnvironmentImpl (wrapper.graphQlType, directives, wrapper.graphQlType.appliedDirectives, directive, appliedDirective, params)
158
159
}
159
160
160
161
fun buildDirectiveInputType (value : Value <* >): GraphQLInputType ? {
0 commit comments