Table of Contents

Global ID

Important This is the beginning of a much larger implementation, where pretty much anything would be able to be stored as simple Global IDs.

This gem implements its own version of Rails Global ID. The purpose is to identify GraphQL components within your application uniquely. This feature is widely by request caching and request compiling.

How it Looks Like


The Components

The URI is can be composed of:

It will always be gql
Based on the primary namespace of the component, in dash format
The top-most class responsible for the component
For schema fields only, either query, mutation, or subscription
The symbolized name of the object
A URI-compatible list of parameters

How to Use

You can get the GID of any element by calling .to_global_id.to_s or simply .to_gid.to_s. Then, you can call GraphQL::GlobalID.find to get the element of a global id.

:001 > GraphQL::AppSchema[:query][:welcome].to_gid.to_s
    => "gql://base/Schema/query/welcome"
:002 > GraphQL::GlobalID.find("gql://base/Schema/query/welcome")
    => #<Rails::GraphQL::Field::OutputField
       #  GraphQL::AppSchema[:query]
       #  welcome: String!>