Last active
November 28, 2018 07:23
-
-
Save flavio-b/9d5582bf83938aea96dc302f6e3a6c36 to your computer and use it in GitHub Desktop.
Adding new GraphQL client to ShopifyAPI module.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'that_graphql_client' | |
module ShopifyAPI | |
class GraphQLClient < GraphQLClient | |
SHOPIFY_GRAPHQL_ENDPOINT_TEMPLATE = "https://<MYSHOPIFY_DOMAIN>/admin/api/graphql.json" | |
def initialize(**args) | |
raise(ArgumentError, 'Must provide an shop as an argument') unless args[:shop].present? | |
super.tap do |client| | |
client.site = SHOPIFY_GRAPHQL_ENDPOINT_TEMPLATE.sub('<MYSHOPIFY_DOMAIN>', args[:shop].shopify_domain) | |
client.headers.merge!({'X-Shopify-Access-Token' => args[:shop].shopify_token}) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment