Skip to content

Commit 3b85686

Browse files
committed
Adding federation tag directive to ignore
1 parent 8f7a2ee commit 3b85686

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

src/main/resources/federation_built_in_directives.graphqls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ directive @external on FIELD_DEFINITION
66
directive @provides(fields: String!) on FIELD_DEFINITION
77
directive @requires(fields: _FieldSet!) on FIELD_DEFINITION
88

9+
directive @tag(name: String!) repeatable on FIELD_DEFINITION | INTERFACE | OBJECT | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.intuit.graphql.orchestrator.federationdirectives.ignoredDirectives
2+
3+
import com.intuit.graphql.orchestrator.ServiceProvider
4+
import com.intuit.graphql.orchestrator.schema.RuntimeGraph
5+
import com.intuit.graphql.orchestrator.stitching.SchemaStitcher
6+
import graphql.schema.GraphQLFieldDefinition
7+
import helpers.BaseIntegrationTestSpecification
8+
9+
class IgnoredDirectiveSpec extends BaseIntegrationTestSpecification {
10+
def "Successful stitching fields with tags"() {
11+
given:
12+
String SCHEMA_WITH_TAGS = '''
13+
type Query {
14+
multipleTagField(id: String): String @tag(name: "tag1") @tag(name: "tag2")
15+
singleTagField: String @tag(name: "soloTag")
16+
noTagField: String
17+
}
18+
'''
19+
20+
ServiceProvider tagProvider = createQueryMatchingService("TAG_SERVICE_PROVIDER",
21+
ServiceProvider.ServiceType.FEDERATION_SUBGRAPH, SCHEMA_WITH_TAGS, null)
22+
List<ServiceProvider> services = List.of(tagProvider)
23+
24+
when:
25+
RuntimeGraph actualRuntimeGraph = SchemaStitcher.newBuilder()
26+
.services(services).build().stitchGraph()
27+
28+
then:
29+
actualRuntimeGraph != null
30+
actualRuntimeGraph.addtionalDirectives.stream().anyMatch { it -> it.name == "tag" }
31+
GraphQLFieldDefinition multipleTagGqlDef = actualRuntimeGraph.executableSchema.queryType.getFieldDefinition("multipleTagField")
32+
multipleTagGqlDef.directives.size() == 2
33+
multipleTagGqlDef.getDirectives().get(0).getArgument("name").argumentValue.getValue() == "tag1"
34+
multipleTagGqlDef.getDirectives().get(1).getArgument("name").argumentValue.getValue() == "tag2"
35+
36+
GraphQLFieldDefinition singleTagGqlDef = actualRuntimeGraph.executableSchema.queryType.getFieldDefinition("singleTagField")
37+
singleTagGqlDef.directives.size() == 1
38+
singleTagGqlDef.getDirectives().get(0).getArgument("name").argumentValue.getValue() == "soloTag"
39+
40+
actualRuntimeGraph.executableSchema.queryType.getFieldDefinition("noTagField").directives.size() == 0
41+
}
42+
}

0 commit comments

Comments
 (0)