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

Update overview example for federation 2 #1741

Merged
merged 1 commit into from
Apr 18, 2022
Merged
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
65 changes: 39 additions & 26 deletions docs/source/federated-types/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type Query {

type User @key(fields: "id") {
id: ID!
username: String!
username: String! @shareable
}

# (Subgraph schemas include
Expand Down Expand Up @@ -111,65 +111,78 @@ Here's the supergraph schema composed with [the subgraph schemas above](#subgrap

```graphql
schema
@core(feature: "https://specs.apollo.dev/core/v0.2"),
@core(feature: "https://specs.apollo.dev/join/v0.1", for: EXECUTION)
@link(url: "https://specs.apollo.dev/link/v1.0")
@link(url: "https://specs.apollo.dev/join/v0.2", for: EXECUTION)
{
query: Query
}

directive @core(feature: String!, as: String, for: core__Purpose) repeatable on SCHEMA

directive @join__field(graph: join__Graph, requires: join__FieldSet, provides: join__FieldSet) on FIELD_DEFINITION
directive @join__field(graph: join__Graph!, requires: join__FieldSet, provides: join__FieldSet, type: String, external: Boolean, override: String, usedOverridden: Boolean) repeatable on FIELD_DEFINITION | INPUT_FIELD_DEFINITION

directive @join__type(graph: join__Graph!, key: join__FieldSet) repeatable on OBJECT | INTERFACE
directive @join__graph(name: String!, url: String!) on ENUM_VALUE

directive @join__owner(graph: join__Graph!) on OBJECT | INTERFACE
directive @join__implements(graph: join__Graph!, interface: String!) repeatable on OBJECT | INTERFACE

directive @join__graph(name: String!, url: String!) on ENUM_VALUE
directive @join__type(graph: join__Graph!, key: join__FieldSet, extension: Boolean! = false, resolvable: Boolean! = true) repeatable on OBJECT | INTERFACE | UNION | ENUM | INPUT_OBJECT | SCALAR

enum core__Purpose {
EXECUTION
SECURITY
}
directive @link(url: String, as: String, for: link__Purpose, import: [link__Import]) repeatable on SCHEMA

scalar join__FieldSet

enum join__Graph {
USERS @join__graph(name: "users" url: "http://localhost:4001")
PRODUCTS @join__graph(name: "products" url: "http://localhost:4002")
REVIEWS @join__graph(name: "reviews" url: "http://localhost:4003")
PRODUCTS @join__graph(name: "products", url: "http://localhost:4003/graphql")
REVIEWS @join__graph(name: "reviews", url: "http://localhost:4002/graphql")
USERS @join__graph(name: "users", url: "http://localhost:4001/graphql")
}

scalar link__Import

enum link__Purpose {
"""
`SECURITY` features provide metadata necessary to securely resolve fields.
"""
SECURITY

"""
`EXECUTION` features provide metadata necessary for operation execution.
"""
EXECUTION
}

type Product
@join__owner(graph: PRODUCTS)
@join__type(graph: PRODUCTS, key: "upc")
@join__type(graph: REVIEWS, key: "upc")
{
upc: String!
name: String! @join__field(graph: PRODUCTS)
price: Int @join__field(graph: PRODUCTS)
reviews: [Review] @join__field(graph: REVIEWS)
upc: String! @join__field(graph: PRODUCTS)
}

type Query {
me: User @join__field(graph: USERS)
type Query
@join__type(graph: PRODUCTS)
@join__type(graph: REVIEWS)
@join__type(graph: USERS)
{
topProducts(first: Int = 5): [Product] @join__field(graph: PRODUCTS)
me: User @join__field(graph: USERS)
}

type Review {
author: User @join__field(graph: REVIEWS, provides: "username")
type Review
@join__type(graph: REVIEWS)
{
body: String
author: User @join__field(graph: REVIEWS, provides: "username")
product: Product
}

type User
@join__owner(graph: USERS)
@join__type(graph: USERS, key: "id")
@join__type(graph: REVIEWS, key: "id")
@join__type(graph: USERS, key: "id")
{
id: ID! @join__field(graph: USERS)
id: ID!
username: String! @join__field(graph: REVIEWS, external: true) @join__field(graph: USERS)
reviews: [Review] @join__field(graph: REVIEWS)
username: String! @join__field(graph: USERS)
}
```

Expand Down