graphql_federated_graph/directives/
extension.rs

1use crate::{ExtensionId, StringId, SubgraphId, Value};
2
3pub const EXTENSION_LINK_ENUM: &str = "extension__Link";
4pub const EXTENSION_LINK_DIRECTIVE: &str = "extension__link";
5pub const EXTENSION_DIRECTIVE_DIRECTIVE: &str = "extension__directive";
6
7/// ```ignore,graphl
8/// """
9/// An instance of a directive imported from an extension. The `name` and `arguments` arguments
10/// are a hoisted version of the original directive. We do this so we can add the `graph` and
11/// `extension` arguments.
12/// """
13/// directive @extension__directive(
14///   "Which subgraph the directive comes from"
15///   graph: join__Graph!
16///   "Which extension the directive is imported from"
17///   extension: grafbase__Extension!
18///   "The name of the directive. Composition has removed the import prefix if there was one in the original subgraph schema."
19///   name: String!
20///   arguments: DirectiveArguments
21/// ) repeatable ON FIELD | SCHEMA | SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINITION | INTERFACE | UNION | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION
22/// ```
23#[derive(PartialEq, PartialOrd, Clone, Debug)]
24pub struct ExtensionDirective {
25    pub subgraph_id: SubgraphId,
26    pub extension_id: ExtensionId,
27    pub name: StringId,
28    pub arguments: Option<Vec<(StringId, Value)>>,
29}
30
31/// ```ignore,graphl
32/// """
33/// The directive that associates values of the `extension__Link` enum to the extension's url.
34/// """
35/// directive @extension__link(
36///   """
37///   The `@link()`ed extension's url, including name and version.
38///   """
39///   url: String!
40///   """
41///   The directives on schema definitions and extensions that are associated with the extension.
42///   """
43///   schemaDirectives: [extension__LinkSchemaDirective!]
44/// ) repeatable on ENUM_VALUE
45///
46/// ```
47#[derive(PartialEq, PartialOrd, Clone, Debug)]
48pub struct ExtensionLinkDirective {
49    pub url: StringId,
50    pub schema_directives: Vec<ExtensionLinkSchemaDirective>,
51}
52
53/// ```ignore,graphql
54/// input extension__LinkSchemaDirective {
55///    graph: join__Graph!
56///    name: String!
57///    arguments: DirectiveArguments
58/// }
59/// ```
60#[derive(PartialEq, PartialOrd, Clone, Debug)]
61pub struct ExtensionLinkSchemaDirective {
62    pub subgraph_id: SubgraphId,
63    pub name: StringId,
64    pub arguments: Option<Vec<(StringId, Value)>>,
65}