Graphql: Difference between revisions

From wikinotes
Line 46: Line 46:
|}
|}
</blockquote><!-- clients -->
</blockquote><!-- clients -->
= Introspection =
<blockquote>
== List Types ==
<source lang="bash">
{ __schema { types { name } } }                    # list all types
{ __schema { mutationType { fields { name } } } }  # list all mutations
{ __schema { queryType { fields { name } } } }    # list all queries
</source>
== Query Available Fields ==
<source lang="bash">
{
  __type(name: "Droid") {  # GraphQL type we want fields from
    name
    fields {
      name
      type {
        name
        kind
      }
    }
  }
}
</source>
Returns all fields, and their type info.
== Query Type info ==
<source lang="bash">
{
  __type(name: "Shop") {
    fields {
      name
      description
    }
  }
}
</source>
</blockquote><!-- tips/tricks -->

Revision as of 02:34, 3 September 2021

GraphQL is an alternative to REST APIs that enables you to query exactly what you need using a single HTTP request, rather than several.

TODO:

These notes are bad. host, validate, and reorganize

Documentation

docs https://graphql.org/learn/
introspection docs https://graphql.org/learn/introspection/

Notes

graphql: basics
graphql usage
graphql queries
graphql mutations
graphql: datatypes
graphql: schemas
grpahql: syntax

Clients

graphql: graphiql web client
graphqurl cli interpreter