Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: include full @link directive definition #352

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static com.apollographql.federation.graphqljava.directives.LinkDirectiveProcessor.loadFederationImportedDefinitions;

import graphql.language.DirectiveDefinition;
import graphql.language.EnumTypeDefinition;
import graphql.language.FieldDefinition;
import graphql.language.ObjectTypeDefinition;
import graphql.language.SDLNamedDefinition;
Expand Down Expand Up @@ -160,16 +161,18 @@ private static RuntimeWiring ensureFederationV2DirectiveDefinitionsExist(
if (def instanceof DirectiveDefinition
&& !typeRegistry.getDirectiveDefinition(def.getName()).isPresent()) {
typeRegistry.add(def);
}
if (def instanceof ScalarTypeDefinition
&& !runtimeWiring.getScalars().containsKey(def.getName())) {
} else if (def instanceof ScalarTypeDefinition
&& !typeRegistry.scalars().containsKey(def.getName())) {
typeRegistry.add(def);
scalarTypesToAdd.add(
GraphQLScalarType.newScalar()
.name(def.getName())
.description(null)
.coercing(_Any.type.getCoercing())
.build());
} else if (def instanceof EnumTypeDefinition
&& !typeRegistry.types().containsKey(def.getName())) {
typeRegistry.add(def);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.apollographql.federation.graphqljava.exceptions.UnsupportedRenameException;
import graphql.language.DirectiveDefinition;
import graphql.language.EnumTypeDefinition;
import graphql.language.NamedNode;
import graphql.language.Node;
import graphql.language.NodeVisitorStub;
Expand Down Expand Up @@ -43,6 +44,9 @@ protected TraversalControl visitNode(Node node, TraverserContext<Node> context)
} else if (node instanceof DirectiveDefinition) {
String newName = newName(((NamedNode<?>) node).getName(), fed2Imports, true);
newNode = ((DirectiveDefinition) node).transform(builder -> builder.name(newName));
} else if (node instanceof EnumTypeDefinition) {
String newName = newName(((NamedNode<?>) node).getName(), fed2Imports, true);
newNode = ((EnumTypeDefinition) node).transform(builder -> builder.name(newName));
}
if (newNode != null) {
return changeNode(context, newNode);
Expand Down Expand Up @@ -78,7 +82,7 @@ private String newName(String name, Map<String, String> fed2Imports, boolean isD
} else {
if (name.equals("inaccessible") || name.equals("tag")) {
return name;
} else if (name.equals("Import")) {
} else if (name.equals("Import") || name.equals("Purpose")) {
return "link__" + name;
} else {
// apply default namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ scalar FieldSet
directive @link(
url: String!,
as: String,
import: [Import])
import: [Import],
for: Purpose)
repeatable on SCHEMA

scalar Import

enum Purpose {
SECURITY
EXECUTION
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,26 @@ directive @tag(name: String!) repeatable on
| INPUT_FIELD_DEFINITION
scalar FieldSet

#
# federation-v2.1
#

directive @composeDirective(name: String!) repeatable on SCHEMA

#
# https://specs.apollo.dev/link/v1.0/link-v1.0.graphql
#

directive @link(
url: String!,
as: String,
import: [Import])
import: [Import],
for: Purpose)
repeatable on SCHEMA

scalar Import

enum Purpose {
SECURITY
EXECUTION
}

#
# federation-v2.1
#

directive @composeDirective(name: String!) repeatable on SCHEMA
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,30 @@ directive @tag(name: String!) repeatable on
| INPUT_FIELD_DEFINITION
scalar FieldSet

#
# federation-v2.1
#

directive @composeDirective(name: String!) repeatable on SCHEMA

#
# https://specs.apollo.dev/link/v1.0/link-v1.0.graphql
#

directive @link(
url: String!,
as: String,
import: [Import])
import: [Import],
for: Purpose)
repeatable on SCHEMA

scalar Import

enum Purpose {
SECURITY
EXECUTION
}

#
# federation-v2.1
#

directive @composeDirective(name: String!) repeatable on SCHEMA

#
# federation-v2.2
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,30 @@ directive @tag(name: String!) repeatable on
| INPUT_FIELD_DEFINITION
scalar FieldSet

#
# federation-v2.1
#

directive @composeDirective(name: String!) repeatable on SCHEMA

#
# https://specs.apollo.dev/link/v1.0/link-v1.0.graphql
#

directive @link(
url: String!,
as: String,
import: [Import])
import: [Import],
for: Purpose)
repeatable on SCHEMA

scalar Import

enum Purpose {
SECURITY
EXECUTION
}

#
# federation-v2.1
#

directive @composeDirective(name: String!) repeatable on SCHEMA

#
# federation-v2.2
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,17 @@ scalar FieldSet
directive @link(
url: String!,
as: String,
import: [Import])
import: [Import],
for: Purpose)
repeatable on SCHEMA

scalar Import

enum Purpose {
SECURITY
EXECUTION
}

#
# federation-v2.1
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ directive @inaccessible on SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINIT

directive @key(fields: FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE

directive @link(as: String, import: [link__Import], url: String!) repeatable on SCHEMA
directive @link(as: String, for: link__Purpose, import: [link__Import], url: String!) repeatable on SCHEMA

directive @requiresScopes(scopes: [[Scope!]!]!) on SCALAR | OBJECT | FIELD_DEFINITION | INTERFACE | ENUM

Expand All @@ -48,6 +48,11 @@ type _Service {
sdl: String!
}

enum link__Purpose {
EXECUTION
SECURITY
}

scalar FieldSet

scalar Scope
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ directive @inaccessible on SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINIT

directive @key(fields: federation__FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE

directive @link(as: String, import: [link__Import], url: String!) repeatable on SCHEMA
directive @link(as: String, for: link__Purpose, import: [link__Import], url: String!) repeatable on SCHEMA

directive @myDirective(foo: String!) on FIELD_DEFINITION

Expand All @@ -46,6 +46,11 @@ type _Service {
sdl: String!
}

enum link__Purpose {
EXECUTION
SECURITY
}

scalar _Any

scalar federation__FieldSet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ directive @inaccessible on SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINIT

directive @key(fields: federation__FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE

directive @link(as: String, import: [link__Import], url: String!) repeatable on SCHEMA
directive @link(as: String, for: link__Purpose, import: [link__Import], url: String!) repeatable on SCHEMA

directive @tag(name: String!) repeatable on SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINITION | INTERFACE | UNION | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION

Expand All @@ -50,6 +50,11 @@ type _Service {
sdl: String!
}

enum link__Purpose {
EXECUTION
SECURITY
}

scalar _Any

scalar federation__FieldSet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ directive @inaccessible on SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINIT

directive @key(fields: federation__FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE

directive @link(as: String, import: [link__Import], url: String!) repeatable on SCHEMA
directive @link(as: String, for: link__Purpose, import: [link__Import], url: String!) repeatable on SCHEMA

directive @tag(name: String!) repeatable on SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINITION | INTERFACE | UNION | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION

Expand All @@ -38,6 +38,11 @@ type _Service {
sdl: String!
}

enum link__Purpose {
EXECUTION
SECURITY
}

scalar _Any

scalar federation__FieldSet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ directive @interfaceObject on OBJECT

directive @key(fields: federation__FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE

directive @link(as: String, import: [link__Import], url: String!) repeatable on SCHEMA
directive @link(as: String, for: link__Purpose, import: [link__Import], url: String!) repeatable on SCHEMA

directive @override(from: String!) on FIELD_DEFINITION

Expand Down Expand Up @@ -92,6 +92,11 @@ type _Service {
sdl: String!
}

enum link__Purpose {
EXECUTION
SECURITY
}

scalar _Any

scalar federation__FieldSet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ directive @inaccessible on SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINIT

directive @key(fields: federation__FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE

directive @link(as: String, import: [link__Import], url: String!) repeatable on SCHEMA
directive @link(as: String, for: link__Purpose, import: [link__Import], url: String!) repeatable on SCHEMA

directive @tag(name: String!) repeatable on SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINITION | INTERFACE | UNION | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION

Expand Down Expand Up @@ -58,6 +58,11 @@ type _Service {
sdl: String!
}

enum link__Purpose {
EXECUTION
SECURITY
}

scalar _Any

scalar federation__FieldSet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ directive @interfaceObject on OBJECT

directive @key(fields: federation__FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE

directive @link(as: String, import: [link__Import], url: String!) repeatable on SCHEMA
directive @link(as: String, for: link__Purpose, import: [link__Import], url: String!) repeatable on SCHEMA

directive @tag(name: String!) repeatable on SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINITION | INTERFACE | UNION | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION

Expand All @@ -43,6 +43,11 @@ type _Service {
sdl: String!
}

enum link__Purpose {
EXECUTION
SECURITY
}

scalar _Any

scalar federation__FieldSet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ directive @inaccessible on SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINIT

directive @key(fields: federation__FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE

directive @link(as: String, import: [link__Import], url: String!) repeatable on SCHEMA
directive @link(as: String, for: link__Purpose, import: [link__Import], url: String!) repeatable on SCHEMA

directive @tag(name: String!) repeatable on SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINITION | INTERFACE | UNION | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION

Expand All @@ -48,6 +48,11 @@ type _Service {
sdl: String!
}

enum link__Purpose {
EXECUTION
SECURITY
}

scalar _Any

scalar federation__FieldSet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ directive @federation__requires(fields: federation__FieldSet!) on FIELD_DEFINITI

directive @inaccessible on SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINITION | INTERFACE | UNION | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION

directive @link(as: String, import: [link__Import], url: String!) repeatable on SCHEMA
directive @link(as: String, for: link__Purpose, import: [link__Import], url: String!) repeatable on SCHEMA

directive @myKey(fields: federation__FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE

Expand Down Expand Up @@ -57,6 +57,11 @@ type _Service {
sdl: String!
}

enum link__Purpose {
EXECUTION
SECURITY
}

scalar federation__FieldSet

scalar link__Import
Loading
Loading