GraphQL
  • 03 Jan 2022
  • 1 Minute to read
  • Contributors
  • Dark
    Light
  • PDF

GraphQL

  • Dark
    Light
  • PDF

Article summary

The EchoStream API is built using GraphQL. GraphQL is simpler, more descriptive, and faster than typical RESTful APIs.

"GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data. GraphQL provides a complete and understandable description of the data in your API, gives clients the power to ask for exactly what they need and nothing more, makes it easier to evolve APIs over time, and enables powerful developer tools." - graphql.org

Simplistically, a GraphQL schema is composed of Types and Fields, where Fields are contained by Types. Fields may require Arguments, thereby effectively becoming methods.

GraphQL can be used to approximate an Object-Oriented schema, and this is exactly what we have tried to accomplish in the EchoStream API. Operations where you do not already have an Echo object can be found in either the Mutation or the Query types. For example, to create a new Edge object you would call Mutation.CreateEdge, and to retrieve an existing Edge you would call Query.GetEdge.

Once you have the Edge (either through creation or getting), you could retrive the attribute maxReceiveCount or you could call Purge to purge the Edge of all current Messages.

Naming Conventions

  • All names use camel case.
  • All Type names begin with uppercase
  • All attribute names begin with lowercase
    • Attributes never have Arguments
  • All method names begin with uppercase
    • Methods may or may not have Arguments
  • Methods that are "global" are in the Mutation or the Query Types
  • Methods that require an Echo object are in the associated object Type (e.g. - the Edge.Purge example above)

What's Next