-
-
Notifications
You must be signed in to change notification settings - Fork 438
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Apollo Federation v2, except for federated tracing
- Loading branch information
Showing
21 changed files
with
654 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Nuwave\Lighthouse\Federation\Directives; | ||
|
||
use Nuwave\Lighthouse\Schema\Directives\BaseDirective; | ||
|
||
class ComposeDirectiveDirective extends BaseDirective | ||
{ | ||
public const NAME = 'composeDirective'; | ||
|
||
public static function definition(): string | ||
{ | ||
return /* @lang GraphQL */ <<<'GRAPHQL' | ||
""" | ||
Indicates to composition that all uses of a particular custom type system directive | ||
in the subgraph schema should be preserved in the supergraph schema | ||
(by default, composition omits most directives from the supergraph schema). | ||
```graphql | ||
extend schema | ||
@link(url: "https://myspecs.dev/myDirective/v1.0", import: ["@myDirective"]) | ||
@composeDirective(name: "@myDirective") | ||
``` | ||
https://www.apollographql.com/docs/federation/federated-types/federated-directives#composedirective | ||
""" | ||
directive @composeDirective(name: String!) repeatable on SCHEMA | ||
GRAPHQL; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Nuwave\Lighthouse\Federation\Directives; | ||
|
||
use Nuwave\Lighthouse\Schema\Directives\BaseDirective; | ||
|
||
class InaccessibleDirective extends BaseDirective | ||
{ | ||
public const NAME = 'inaccessible'; | ||
|
||
public static function definition(): string | ||
{ | ||
return /* @lang GraphQL */ <<<'GRAPHQL' | ||
""" | ||
Indicates that a definition in the subgraph schema should be omitted from the router's API schema, | ||
even if that definition is also present in other subgraphs. | ||
This means that the field is not exposed to clients at all. | ||
```graphql | ||
type Position @shareable { | ||
x: Int! | ||
y: Int! | ||
z: Int! @inaccessible | ||
} | ||
``` | ||
An @inaccessible field or type is not omitted from the supergraph schema, so the router | ||
still knows it exists (but clients can't include it in operations). | ||
This is what enables the router to use an @inaccessible field as part of an entity's @key | ||
when combining entity fields from multiple subgraphs. | ||
If a type is marked @inaccessible, all fields that return that type must also be marked @inaccessible. | ||
Otherwise, a composition error occurs. | ||
https://www.apollographql.com/docs/federation/federated-types/federated-directives#inaccessible | ||
""" | ||
directive @inaccessible on FIELD_DEFINITION | INTERFACE | OBJECT | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION | ||
GRAPHQL; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Nuwave\Lighthouse\Federation\Directives; | ||
|
||
use Nuwave\Lighthouse\Schema\Directives\BaseDirective; | ||
|
||
class InterfaceObjectDirective extends BaseDirective | ||
{ | ||
public const NAME = 'interfaceObject'; | ||
|
||
public static function definition(): string | ||
{ | ||
return /* @lang GraphQL */ <<<'GRAPHQL' | ||
""" | ||
Indicates that an object definition serves as an abstraction of another subgraph's entity interface. | ||
This abstraction enables a subgraph to automatically contribute fields to all entities that implement a particular entity interface. | ||
During composition, the fields of every @interfaceObject are added both to their corresponding interface definition | ||
and to all entity types that implement that interface. | ||
https://www.apollographql.com/docs/federation/federated-types/federated-directives#interfaceobject | ||
""" | ||
directive @interfaceObject on OBJECT | ||
GRAPHQL; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Nuwave\Lighthouse\Federation\Directives; | ||
|
||
use Nuwave\Lighthouse\Schema\Directives\BaseDirective; | ||
|
||
class LinkDirective extends BaseDirective | ||
{ | ||
public const NAME = 'link'; | ||
|
||
public static function definition(): string | ||
{ | ||
return /* @lang GraphQL */ <<<'GRAPHQL' | ||
""" | ||
This directive links definitions from an external specification to this schema. | ||
Every Federation 2 subgraph uses the @link directive to import the other federation-specific directives. | ||
```graphql | ||
extend schema @link(url: "https://specs.apollo.dev/federation/v2.3") | ||
``` | ||
https://www.apollographql.com/docs/federation/federated-types/federated-directives#the-link-directive | ||
""" | ||
directive @link(url: String!, as: String, for: link__Purpose, import: [link__Import]) repeatable on SCHEMA | ||
GRAPHQL; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Nuwave\Lighthouse\Federation\Directives; | ||
|
||
use Nuwave\Lighthouse\Schema\Directives\BaseDirective; | ||
|
||
class OverrideDirective extends BaseDirective | ||
{ | ||
public const NAME = 'override'; | ||
|
||
public static function definition(): string | ||
{ | ||
return /* @lang GraphQL */ <<<'GRAPHQL' | ||
""" | ||
Indicates that an object field is now resolved by this subgraph instead of another subgraph | ||
where it's also defined. This enables you to migrate a field from one subgraph to another. | ||
You can apply @override to entity fields and fields of the root operation types (such as Query and Mutation). | ||
```graphql | ||
type Product @key(fields: "id") { | ||
id: ID! | ||
inStock: Boolean! @override(from: "Products") | ||
} | ||
``` | ||
You can apply @override to a @shareable field. If you do, only the subgraph you provide | ||
in the from argument no longer resolves that field. Other subgraphs can still resolve the field. | ||
Only one subgraph can @override any given field. | ||
If multiple subgraphs attempt to @override the same field, a composition error occurs. | ||
https://www.apollographql.com/docs/federation/federated-types/federated-directives#override | ||
""" | ||
directive @override(from: String!) on FIELD_DEFINITION | ||
GRAPHQL; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Nuwave\Lighthouse\Federation\Directives; | ||
|
||
use Nuwave\Lighthouse\Schema\Directives\BaseDirective; | ||
|
||
class ShareableDirective extends BaseDirective | ||
{ | ||
public const NAME = 'shareable'; | ||
|
||
public static function definition(): string | ||
{ | ||
return /* @lang GraphQL */ <<<'GRAPHQL' | ||
""" | ||
Indicates that an object type's field is allowed to be resolved by multiple subgraphs | ||
(by default in Federation 2, object fields can be resolved by only one subgraph). | ||
If applied to an object type definition, all of that type's fields are considered @shareable. | ||
```graphql | ||
type Position { | ||
x: Int! @shareable | ||
y: Int! @shareable | ||
} | ||
type Position @shareable { | ||
x: Int! | ||
y: Int! | ||
} | ||
``` | ||
If a field is marked @shareable in any subgraph, it must be marked as either | ||
@shareable or @external in every Federation 2 subgraph that defines it. | ||
If a field is included in an entity's @key directive, that field is automatically | ||
considered @shareable and the directive is not required in the corresponding subgraph(s). | ||
https://www.apollographql.com/docs/federation/federated-types/federated-directives#shareable | ||
""" | ||
directive @shareable on FIELD_DEFINITION | OBJECT | ||
GRAPHQL; | ||
} | ||
} |
Oops, something went wrong.