schema
  @link(url: "https://specs.apollo.dev/link/v1.0")
  @link(url: "https://specs.apollo.dev/join/v0.3", for: EXECUTION)
{
  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

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

type ArticleResult
  @join__type(graph: SEARCHSUBGRAPH, key: "id")
{
  id: ID!
  sections: [Section]
}

type EntityCollectionSection
  @join__type(graph: ARTWORKSUBGRAPH, key: "id")
  @join__type(graph: SEARCHSUBGRAPH, key: "id")
{
  id: ID!
  title: String @join__field(graph: ARTWORKSUBGRAPH)
  artwork(params: String): String @join__field(graph: ARTWORKSUBGRAPH)
}

type GallerySection
  @join__type(graph: ARTWORKSUBGRAPH, key: "id")
  @join__type(graph: SEARCHSUBGRAPH, key: "id")
{
  id: ID!
  artwork(params: String): String @join__field(graph: ARTWORKSUBGRAPH)
}

scalar join__FieldSet

enum join__Graph {
  ARTWORKSUBGRAPH @join__graph(name: "artworkSubgraph", url: "http://localhost:4042")
  SEARCHSUBGRAPH @join__graph(name: "searchSubgraph", url: "http://localhost:4041")
}

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 MovieResult
  @join__type(graph: SEARCHSUBGRAPH, key: "id")
{
  id: ID!
  sections: [Section]
}

type Query
  @join__type(graph: ARTWORKSUBGRAPH)
  @join__type(graph: SEARCHSUBGRAPH)
{
  me: String @join__field(graph: ARTWORKSUBGRAPH)
  search: [SearchResult] @join__field(graph: SEARCHSUBGRAPH)
  searchListOfList: [[SearchResult]] @join__field(graph: SEARCHSUBGRAPH)
  searchListOfListOfList: [[[SearchResult]]] @join__field(graph: SEARCHSUBGRAPH)
}

union SearchResult
  @join__type(graph: SEARCHSUBGRAPH)
  @join__unionMember(graph: SEARCHSUBGRAPH, member: "MovieResult")
  @join__unionMember(graph: SEARCHSUBGRAPH, member: "ArticleResult")
 = MovieResult | ArticleResult

union Section
  @join__type(graph: SEARCHSUBGRAPH)
  @join__unionMember(graph: SEARCHSUBGRAPH, member: "EntityCollectionSection")
  @join__unionMember(graph: SEARCHSUBGRAPH, member: "GallerySection")
 = EntityCollectionSection | GallerySection
