Skip to content

Instantly share code, notes, and snippets.

@pcmanus
Created March 8, 2022 09:35
Show Gist options
  • Save pcmanus/46a9f81b9edb4768e6f322b3242dc9b1 to your computer and use it in GitHub Desktop.
Save pcmanus/46a9f81b9edb4768e6f322b3242dc9b1 to your computer and use it in GitHub Desktop.
@Shareable and @link definitions
// Full definitions
"""
Marks a field as "shareable" (allowed to be resolved by more than one subgraph).
Can be used on an object type as a shortcut for marking all the fields of the type definition.
"""
directive @shareable on FIELD_DEFINITION | OBJECT
"""
The name of an element to import from an @linked feature in the top-level
namespace (meaning that this name can be used with prefixing by the feature
name).
This can be either an element name as a `String`, or to allow importing the
element under a custom name, a input object of the form:
```
{ name: "name_of_element_to_import", alias: "imported_named" }
```
"""
scalar link__Import
"""
Optional purpose for a linked feature.
"""
enum link__Purpose {
"""
`SECURITY` features provide metadata necessary to securely resolve fields.
"""
SECURITY
"""
`EXECUTION` features provide metadata necessary for operation execution.
"""
EXECUTION
}
"""
Links to a core feature (a set of type system declarations with a specific purpose).
"""
directive @link(
""" Url of the linked core feature. """
url: String!,
"""
Optional list of element names to import in the top-level namesapce.
Elements of the feature not part of this list can only be referenced by
prefixing the element named by the feature name (for instance, if the
`@key` is not imported in this list for the `federation` feature, it
can still be refered to using `@federation__key`).
"""
import: [link__Import],
"""
Optional name to use as alias for the feature name in the document
in which this is used.
"""
as: String,
"""
Optional purpose of the linked feature.
"""
for: link__Purpose
) repeatable on SCHEMA
// Alternative sets of simplified definitions that will work for users in
// subgraphs in practice and may save us from having to discuss some concepts
// we're not quiet ready to discuss.
"""
Marks a field as "shareable" (allowed to be resolved by more than one subgraph).
Can be used on an object type as a shortcut for marking all the fields of the type definition.
"""
directive @shareable on FIELD_DEFINITION | OBJECT
"""
The name of an element to import from an @linked feature in the top-level
namespace (meaning that this name can be used with prefixing by the feature
name).
This can be either an element name as a `String`, or to allow importing the
element under a custom name, a input object of the form:
```
{ name: "name_of_element_to_import", alias: "imported_named" }
```
"""
scalar link__Import
"""
Links to a core feature (a set of type system declarations with a specific purpose).
"""
directive @link(
""" Url of the linked core feature. """
url: String!,
"""
Optional list of element names to import in the top-level namesapce.
Elements of the feature not part of this list can only be referenced by
prefixing the element named by the feature name (for instance, if the
`@key` is not imported in this list for the `federation` feature, it
can still be refered to using `@federation__key`).
"""
import: [link__Import],
) repeatable on SCHEMA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment