Module: GQLi::Contentful

Defined in:
lib/gqli/clients/contentful.rb

Overview

Module for creating a Contentful GraphQL client

Class Method Summary collapse

Class Method Details

.create(space, access_token, environment: nil, validate_query: true) ⇒ Object

Creates a Contentful GraphQL client



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/gqli/clients/contentful.rb', line 7

def self.create(space, access_token, environment: nil, validate_query: true)
  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
  )
end