MONEI / Shopify-api-node

Node Shopify connector sponsored by MONEI
https://monei.com/shopify-payment-gateway/
MIT License
947 stars 278 forks source link

Updating Article type definitions #653

Closed ryanbalsdon closed 3 months ago

ryanbalsdon commented 3 months ago

This patch is updating Article type definitions to match the documentation on the Shopify Dev Portal. The largest change is the inclusion of a src and alt field on the image, which lets Shopify download an image on your behalf. The remaining fields of both create and update actions have been marked as optional too. The only required field listed in the documentation is the Article ID on updates.

Added fields to the image type

The REST API documentation has two examples for adding images, one with the existing base64 data as attachment (called "Create an article with a base64 encoded image") and another with the src and alt fields (called "Create an article with an image, which will be downloaded by Shopify"). The image definition from the second example is copied below.

article.image = {
  "src": "http://example.com/rails_logo.gif",
  "alt": "Rails logo"
};

I think this change was mentioned in an old issue too.

Marked all fields as optional

The REST API documentation lists only two fields as required: api_version and blog_id. Since the Blog ID is part of the URL (and obviously required for that) and the API Version comes through a header (and not even present in the examples given), I'm not sure why they bothered to list them.

Why not use the GraphQL API?

Unfortunately, the Article mutations are in the unstable graphql branch so they're at least a few months out from hitting a full release. Interestingly though, the GraphQL API documentation also marks none of the fields as required, so the intention here will probably continue.

coveralls commented 3 months ago

Coverage Status

coverage: 100.0%. remained the same when pulling 11ea4d19af2a8bf1ffe1b1d7f1e72a07d7e9ca80 on ryanbalsdon:update-article-type-definitions into fd6d034440fd08fd9a97765c37152ecc5a6e7d5a on MONEI:master.

lpinca commented 3 months ago

Thank you.