schema
    @link(url: "https://specs.apollo.dev/link/v1.0")
    @link(url: "https://specs.apollo.dev/join/v0.3", for: EXECUTION)
    @link(url: "https://specs.apollo.dev/tag/v0.3")
    @link(url: "https://specs.apollo.dev/inaccessible/v0.2", for: SECURITY)
    @link(
        url: "https://myspecs.dev/myDirective/v1.0"
        import: ["@myDirective", { name: "@anotherDirective", as: "@hello" }]
    ) {
    query: Query
}

directive @join__enumValue(graph: join__Graph!) repeatable on ENUM_VALUE

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__graph(name: String!, url: String!) on ENUM_VALUE

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

directive @join__type(
    graph: join__Graph!
    key: join__FieldSet
    extension: Boolean! = false
    resolvable: Boolean! = true
    isInterfaceObject: Boolean! = false
) repeatable on OBJECT | INTERFACE | UNION | ENUM | INPUT_OBJECT | SCALAR

directive @join__unionMember(
    graph: join__Graph!
    member: String!
) repeatable on UNION

scalar join__FieldSet

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

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
}

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

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

enum join__Graph {
    INVENTORY @join__graph(name: "inventory", url: "")
    PANDAS @join__graph(name: "pandas", url: "")
    PRODUCTS @join__graph(name: "products", url: "")
    REVIEWS @join__graph(name: "reviews", url: "")
    USERS @join__graph(name: "users", url: "")
}

directive @myDirective(a: String!) on FIELD_DEFINITION

directive @hello on FIELD_DEFINITION

type Product implements ProductItf & SkuItf
    @join__type(graph: INVENTORY, key: "id")
    @join__type(graph: PRODUCTS, key: "id")
    @join__type(graph: PRODUCTS, key: "sku package")
    @join__type(graph: PRODUCTS, key: "sku variation { id }")
    @join__type(graph: REVIEWS, key: "id")
    @join__implements(graph: INVENTORY, interface: "ProductItf")
    @join__implements(graph: PRODUCTS, interface: "ProductItf")
    @join__implements(graph: PRODUCTS, interface: "SkuItf")
    @join__implements(graph: REVIEWS, interface: "ProductItf") {
    id: ID! @tag(name: "hi-from-products")
    dimensions: ProductDimension
        @join__field(graph: INVENTORY, external: true)
        @join__field(graph: PRODUCTS)
    delivery(zip: String): DeliveryEstimates
        @join__field(graph: INVENTORY, requires: "dimensions{size weight}")
    sku: String @join__field(graph: PRODUCTS)
    package: String @join__field(graph: PRODUCTS)
    variation: ProductVariation @join__field(graph: PRODUCTS)
    name: String @hello @join__field(graph: PRODUCTS)
    createdBy: User @join__field(graph: PRODUCTS)
    hidden: String @join__field(graph: PRODUCTS)
    reviewsScore: Float! @join__field(graph: REVIEWS, override: "products")
    oldField: String @join__field(graph: PRODUCTS)
    reviewsCount: Int! @join__field(graph: REVIEWS)
    reviews: [Review!]! @join__field(graph: REVIEWS)
}

type ProductDimension
    @join__type(graph: INVENTORY)
    @join__type(graph: PRODUCTS) {
    size: String
    weight: Float
}

type DeliveryEstimates @join__type(graph: INVENTORY) {
    estimatedDelivery: String
    fastestDelivery: String
}

type Query
    @join__type(graph: INVENTORY)
    @join__type(graph: PANDAS)
    @join__type(graph: PRODUCTS)
    @join__type(graph: REVIEWS)
    @join__type(graph: USERS) {
    allPandas: [Panda] @join__field(graph: PANDAS)
    panda(name: ID!): Panda @join__field(graph: PANDAS)
    allProducts: [ProductItf] @join__field(graph: PRODUCTS)
    product(id: ID!): ProductItf @join__field(graph: PRODUCTS)
    review(id: Int!): Review @join__field(graph: REVIEWS)
}

type Panda @join__type(graph: PANDAS) {
    name: ID!
    favoriteFood: String @tag(name: "nom-nom-nom")
}

type ProductVariation @join__type(graph: PRODUCTS) {
    id: ID!
    name: String
}

type User
    @join__type(graph: PRODUCTS, key: "email")
    @join__type(graph: USERS, key: "email") {
    email: ID! @tag(name: "test-from-users")
    totalProductsCreated: Int
    name: String @join__field(graph: USERS)
}

type Review @join__type(graph: REVIEWS) {
    id: Int!
    body: String!
}

interface ProductItf implements SkuItf
    @join__type(graph: INVENTORY)
    @join__type(graph: PRODUCTS)
    @join__type(graph: REVIEWS)
    @join__implements(graph: PRODUCTS, interface: "SkuItf") {
    id: ID!
    dimensions: ProductDimension
        @join__field(graph: INVENTORY)
        @join__field(graph: PRODUCTS)
    delivery(zip: String): DeliveryEstimates @join__field(graph: INVENTORY)
    sku: String @join__field(graph: PRODUCTS)
    name: String @join__field(graph: PRODUCTS)
    package: String @join__field(graph: PRODUCTS)
    variation: ProductVariation @join__field(graph: PRODUCTS)
    createdBy: User @join__field(graph: PRODUCTS)
    hidden: String @join__field(graph: PRODUCTS) @inaccessible
    oldField: String
        @join__field(graph: PRODUCTS)
        @deprecated(reason: "refactored out")
    reviewsCount: Int! @join__field(graph: REVIEWS)
    reviewsScore: Float! @join__field(graph: REVIEWS)
    reviews: [Review!]! @join__field(graph: REVIEWS)
}

interface SkuItf @join__type(graph: PRODUCTS) {
    sku: String
}

enum ShippingClass @join__type(graph: INVENTORY) @join__type(graph: PRODUCTS) {
    STANDARD
        @join__enumValue(graph: INVENTORY)
        @join__enumValue(graph: PRODUCTS)
    EXPRESS @join__enumValue(graph: INVENTORY) @join__enumValue(graph: PRODUCTS)
    OVERNIGHT @join__enumValue(graph: INVENTORY)
}
