module GQLi::Contentful

Module for creating a Contentful GraphQL client

Public Class Methods

create(space, access_token, environment: nil, validate_query: true, options: {}) click to toggle source

Creates a Contentful GraphQL client

# File lib/gqli/clients/contentful.rb, line 7
def self.create(space, access_token, environment: nil, validate_query: true, options: {})
  api_url = "https://graphql.contentful.com/content/v1/spaces/#{space}"
  api_url += "/environments/#{environment}" unless environment.nil?

  GQLi::Client.new(
    api_url,
    headers: {
      'Authorization' => "Bearer #{access_token}"
    },
    validate_query: validate_query,
    options: options
  )
end