gnikyt / Basic-Shopify-API

A simple API wrapper for Shopify using Guzzle for REST and GraphQL
MIT License
220 stars 66 forks source link

Unable to set header on graphQL for Retrieving Storefront API translations #125

Open wire67 opened 3 years ago

wire67 commented 3 years ago

Unable to set header on graphQL for Retrieving Storefront API translations

We can query the supported resources using the Accept-Language HTTP header, to return translated content to the Storefront API.

Reference: https://shopify.dev/api/examples/i18n-app-translations#retrieving-storefront-api-translations

Issue: I was unable to set the header. My attempt was the following:

      $opt = $options->getGuzzleOptions();
      $opt = array_merge_multi($opt, ['headers' => ['Accept-Language' => 'fr']]);
      $options->setGuzzleOptions($opt);

I can see the header is put into _conditional but it does not seem to be passed further.

the output is also not showing the header:

[headerNames:GuzzleHttp\Psr7\Response:private] => Array
  | (
  | [date] => Date
  | [content-type] => Content-Type
  | [transfer-encoding] => Transfer-Encoding
  | [connection] => Connection
  | [x-sorting-hat-podid] => X-Sorting-Hat-PodId
  | [x-sorting-hat-shopid] => X-Sorting-Hat-ShopId
  | [vary] => Vary
  | [referrer-policy] => Referrer-Policy
  | [x-frame-options] => X-Frame-Options
  | [x-shopid] => X-ShopId
  | [x-shardid] => X-ShardId
  | [x-stats-userid] => X-Stats-UserId
  | [x-stats-apiclientid] => X-Stats-ApiClientId
  | [x-stats-apipermissionid] => X-Stats-ApiPermissionId
  | [x-shopify-api-version] => X-Shopify-API-Version
  | [content-language] => Content-Language
  | [strict-transport-security] => Strict-Transport-Security
  | [x-shopify-stage] => X-Shopify-Stage
  | [content-security-policy] => Content-Security-Policy
  | [x-content-type-options] => X-Content-Type-Options
  | [x-download-options] => X-Download-Options
  | [x-permitted-cross-domain-policies] => X-Permitted-Cross-Domain-Policies
  | [x-xss-protection] => X-XSS-Protection
  | [x-dc] => X-Dc
  | [nel] => NEL
  | [report-to] => Report-To
  | [x-request-id] => X-Request-ID
  | [cf-cache-status] => CF-Cache-Status
  | [expect-ct] => Expect-CT
  | [server] => Server
  | [cf-ray] => CF-RAY
  | [alt-svc] => alt-svc
  | )
ortegafernando commented 2 years ago

Hi, any solution for this? Thanks.