Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Scope chose GraphQL for our API v3 because it offers significantly more flexibility for our integrators. The ability to define precisely the data you want—and only the data you want—is a powerful advantage over the REST API v2 endpoints.

GraphQL lets you replace multiple REST requests with a single call to fetch the data you specify.

...

The Scope GraphQL API represents an architectural and conceptual shift from the Scope REST APIs.

You will likely encounter some new terminology in the GraphQL API reference docs.

Schema

A schema defines a GraphQL API's type system and resides on the GraphQL API server. It describes the complete set of possible data (objects, fields, relationships, everything) that a client can access, including:

  • Allowed operations → queries and mutations.

  • Defined types → scalars, objects, enums, interfaces, unions, and input objects.

Calls from the client are validated and executed against the schema. A client can find information about the schema via introspection. A schema resides on the GraphQL API server. public schema, and a special type of query can help you introspect the schema in real-time. For more information, see "Discovering the Scope GraphQL API."

All calls are validated and executed against the Scope GraphQL public schema:

...

Allowed operations: queries and mutations.

...

" and reference docs.

For other information, such as authentication and rate limit details, check out the guides.

Note that you may need to rely on both the docs and the real-time schema validation to successfully call the GraphQL

...

API.

Field

A field is a unit of data you can retrieve from an object. As the official GraphQL docs say: "The GraphQL query language is basically about selecting fields on objects."

...

GraphQL is introspective. This means you can query ask a GraphQL schema for details about itself.

  • Query __schema to list all types defined in the schema and get details about each:

    Code Block
    query {
      __schema {
        types {
          name
          kind
          description
          fields {
            name
          }
        }
      }
    }
    
  • Query __type to get details about any type:

    Code Block
    query {
      __type(name: "User") {
        name
        kind
        description
        fields {
          name
        }
      }
    }
    
  • You can also run an introspection query of the schema via a GET request:

    Code Block
    $ curl -H "Authorization: Token token" https://cms.scopear.com/api/v3/graphql

    The results are in JSON, so we recommend pretty-printing them for easier reading and searching. You can use a command-line tool like jq or pipe the results into python -m json.tool for this purpose.

    Note: The introspection query is probably the only GET request you'll run in GraphQL. If you're passing a body, the GraphQL request method is POST, whether it's a query or a mutation.run in GraphQL. If you're passing a body, the GraphQL request method is POST, whether it's a query or a mutation.

In addition to executing introspection queries manually, most GraphQL client tools include features that help you navigate the schema in real time as you design queries and mutations. The image below shows one such tool, GraphiQL, with auto-completion (left panel) and embedded documentation (right panel).

...

Resource limitations

The Scope GraphQL API has limitations in place to protect against excessive or abusive calls to Scope's servers.

Node limit

To pass schema validation, all GraphQL API v3 calls must meet these standards:

...

Dividing by 100 and rounding up gives us the final score of the query: 21

Further reading

See “Public SchemaReference Docs” to view reference documentation and learn about the data types available in the GraphQL API public schema. 

...