graphql-composition 0.12.2

An implementation of GraphQL federated schema composition
Documentation
---
source: crates/graphql-composition/tests/composition_tests.rs
expression: Federated SDL
input_file: crates/graphql-composition/tests/composition/descriptions_basic/test.md
---
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/inaccessible/v0.2", for: SECURITY)
{
  query: Query
}

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

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

directive @join__graph(name: String!, url: String) on ENUM_VALUE

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

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

directive @join__enumValue(graph: join__Graph!) on ENUM_VALUE

directive @join__owner(graph: join__Graph!) on OBJECT

"""
Custom scalar to represent the texture profile of tofu.
"""
scalar TextureProfile

scalar join__FieldSet

"""
The Tofu type represents various properties of tofu.
"""
type Tofu
  @join__type(graph: SELFEXPLANATORYTOFU)
  @join__type(graph: TOFU)
{
  """
  The unique ID of the tofu.
  """
  id: ID!
  """
  The name of the tofu.
  """
  name: String!
  """
  Nutritional information about the tofu.
  """
  nutrition: Nutrition
  """
  List of recipes that include this tofu.
  """
  recipes("Which recipes to include. See [RecipeFilter]." filter: RecipeFilter): [Recipe]
  """
  The texture profile of the tofu, expressed through a custom scalar.
  """
  texture: TextureProfile
  """
  The type of tofu (e.g., silken, firm).
  """
  type: TofuType
}

"""
Nutritional information for tofu.
"""
type Nutrition
  @join__type(graph: SELFEXPLANATORYTOFU)
  @join__type(graph: TOFU)
{
  """
  The amount of calories per serving.
  """
  calories: Int
  """
  Total fat content per serving.
  """
  fat: Float
  """
  The amount of protein per serving.
  """
  protein: Float
}

"""
A recipe that includes tofu as an ingredient.
"""
type Recipe
  @join__type(graph: SELFEXPLANATORYTOFU)
  @join__type(graph: TOFU)
{
  """
  Description of the recipe.
  """
  description: String
  """
  The unique ID of the recipe.
  """
  id: ID!
  """
  The ingredients used in the recipe, including tofu.
  """
  ingredients: [FoodItem]
  """
  The name of the recipe.
  """
  name: String!
  """
  The main type of tofu used in this recipe.
  """
  tofuType: TofuType
}

"""
Vegetable type used in tofu recipes.
"""
type Vegetable
  @join__type(graph: SELFEXPLANATORYTOFU)
  @join__type(graph: TOFU)
{
  """
  Name of the vegetable.
  """
  name: String
  """
  Nutritional information of the vegetable.
  """
  nutrition: Nutrition
}

"""
Spice type used in tofu recipes.
"""
type Spice
  @join__type(graph: SELFEXPLANATORYTOFU)
  @join__type(graph: TOFU)
{
  """
  Description of the spice's flavor.
  """
  flavorDescription: String
  """
  Name of the spice.
  """
  name: String
}

type Query
{
  allTheTofus: [Tofu] @join__field(graph: TOFU)
}

"""
Defines different types of tofu.
"""
enum TofuType
  @join__type(graph: SELFEXPLANATORYTOFU)
  @join__type(graph: TOFU)
{
  """
  Silken tofu - soft and smooth, often used in soups and sauces.
  """
  SILKEN @join__enumValue(graph: SELFEXPLANATORYTOFU) @join__enumValue(graph: TOFU)
  """
  Firm tofu - holds its shape well, good for grilling and frying.
  """
  FIRM @join__enumValue(graph: SELFEXPLANATORYTOFU) @join__enumValue(graph: TOFU)
  """
  Extra firm tofu - very dense and solid, ideal for stir-fries.
  """
  EXTRA_FIRM @join__enumValue(graph: SELFEXPLANATORYTOFU) @join__enumValue(graph: TOFU)
}

enum join__Graph
{
  SELFEXPLANATORYTOFU @join__graph(name: "selfExplanatoryTofu", url: "http://example.com/selfExplanatoryTofu")
  TOFU @join__graph(name: "tofu", url: "http://example.com/tofu")
}

"""
Union representing different food items that can be part of a recipe.
"""
union FoodItem
  @join__unionMember(graph: SELFEXPLANATORYTOFU, member: "Tofu")
  @join__unionMember(graph: SELFEXPLANATORYTOFU, member: "Vegetable")
  @join__unionMember(graph: SELFEXPLANATORYTOFU, member: "Spice")
  @join__unionMember(graph: TOFU, member: "Tofu")
  @join__unionMember(graph: TOFU, member: "Vegetable")
  @join__unionMember(graph: TOFU, member: "Spice")
 = Tofu | Vegetable | Spice

"""
Filter criteria for tofu recipes.
"""
input RecipeFilter
  @join__type(graph: SELFEXPLANATORYTOFU)
  @join__type(graph: TOFU)
{
  """
  Minimum required protein content.
  """
  minProtein: Float
  """
  Maximum allowed calorie count.
  """
  maxCalories: Int
}