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

Support "schema" SDL/introspection #1225

Closed
jasonkuhrt opened this issue Oct 26, 2024 · 0 comments · Fixed by #1226
Closed

Support "schema" SDL/introspection #1225

jasonkuhrt opened this issue Oct 26, 2024 · 0 comments · Fixed by #1226

Comments

@jasonkuhrt
Copy link
Member

jasonkuhrt commented Oct 26, 2024

Perceived Problem

This is the SDL produced by async-graphql service examples.

Notice that it does NOT have Query type but rather QueryRoot type.

Graffle currently assumes that the root types are ALWAYS named Query Mutation etc.

This is wrong.

"""
A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.
"""
schema {
  query: QueryRoot
}

interface Character {
  id: String!
  name: String!
  friends: [Character!]!
  appearsIn: [Episode!]!
}

"""A mechanical creature in the Star Wars universe."""
type Droid implements Character {
  """The id of the droid."""
  id: String!

  """The name of the droid."""
  name: String!

  """The friends of the droid, or an empty list if they have none."""
  friends: [Character!]!

  """Which movies they appear in."""
  appearsIn: [Episode!]!

  """The primary function of the droid."""
  primaryFunction: String
}

type DroidConnection {
  """Information to aid in pagination."""
  pageInfo: PageInfo!

  """A list of edges."""
  edges: [DroidEdge!]!

  """A list of nodes."""
  nodes: [Droid!]!
}

"""An edge in a connection."""
type DroidEdge {
  """The item at the end of the edge"""
  node: Droid!

  """A cursor for use in pagination"""
  cursor: String!
}

"""One of the films in the Star Wars Trilogy"""
enum Episode {
  """Released in 1977."""
  NEW_HOPE

  """Released in 1980."""
  EMPIRE

  """Released in 1983."""
  JEDI
}

"""A humanoid creature in the Star Wars universe."""
type Human implements Character {
  """The id of the human."""
  id: String!

  """The name of the human."""
  name: String!

  """The friends of the human, or an empty list if they have none."""
  friends: [Character!]!

  """Which movies they appear in."""
  appearsIn: [Episode!]!

  """The home planet of the human, or null if unknown."""
  homePlanet: String
}

type HumanConnection {
  """Information to aid in pagination."""
  pageInfo: PageInfo!

  """A list of edges."""
  edges: [HumanEdge!]!

  """A list of nodes."""
  nodes: [Human!]!
}

"""An edge in a connection."""
type HumanEdge {
  """The item at the end of the edge"""
  node: Human!

  """A cursor for use in pagination"""
  cursor: String!
}

"""Information about pagination in a connection"""
type PageInfo {
  """When paginating backwards, are there more items?"""
  hasPreviousPage: Boolean!

  """When paginating forwards, are there more items?"""
  hasNextPage: Boolean!

  """When paginating backwards, the cursor to continue."""
  startCursor: String

  """When paginating forwards, the cursor to continue."""
  endCursor: String
}

type QueryRoot {
  hero(
    """
    If omitted, returns the hero of the whole saga. If provided, returns the hero of that particular episode.
    """
    episode: Episode
  ): Character!
  human(
    """id of the human"""
    id: String!
  ): Human
  humans(after: String, before: String, first: Int, last: Int): HumanConnection!
  droid(
    """id of the droid"""
    id: String!
  ): Droid
  droids(after: String, before: String, first: Int, last: Int): DroidConnection!
}

Ideas / Proposed Solution(s)

  • schema type needs to track the mapping
  • find all places where we have hard-coded references to root type names

(note to self: now I understand why there was no constant for root type name in the graphql package.)

@jasonkuhrt jasonkuhrt changed the title support "schema" SDL/introspection Support "schema" SDL/introspection Oct 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant