Shopify / shopify-api-ruby

ShopifyAPI is a lightweight gem for accessing the Shopify admin REST and GraphQL web services.
MIT License
1.06k stars 470 forks source link

Extract REST Resources into standalone Gem #1194

Open nelsonwittwer opened 1 year ago

nelsonwittwer commented 1 year ago

The REST resources have key roles as they provide an interface in interacting with every endpoint of the API as well as casting responses into objects with defined attributes and methods.

These files are all generated from an OpenAPI schema that, ironically, are not yet open to the public. Given how many files are generated across many different versions of the API, this surface area brings a large amount of bugs and the root causes are found upstream in processes the community doesn't have access to. We have immediate plans to move those schemas/logic into the open source sphere, but we'd also like to take this time to extract the resources into their own gem separate from this Gem.

Why extract these resources into their own gem

  1. Fewer breaking changes to the foundational authentication/client level gem.
  2. Encourage more customization. Many of our users were upset about the direction of removing ActiveModel from our resources. By uncoupling these files from the foundational API we open the community up to add features, create their own gems, and better customize their development experience without having to fork the core authentication/client logic of this root gem.
  3. Open up the path for similar GraphQL types / interfaces.

Gem Architecture

Gem Name Job
Shopify API (this gem) Obtain a session, clients for APIs (REST, GraphQL), error handling, webhook management
REST Resources Interfaces to the APIs. Response casting into defined objects with attributes/methods
Shopify App Build Shopify app using Rails conventions. Oauth, webhook processing, persistence, etc
App Template Template demonstrating how to use all these components in one starting boilerplate application
Trehana commented 1 year ago

Another functionality that will be beneficial to be added to the REST Resources gem is to define the number of retries that the method should retry. currently, Shopify API gem does not have this functionality of adding the number of times the request should try. For an example this would be beneficial when tackling the Exceeded 2 calls per second for api client issue.

panckreous commented 1 year ago

hey @nelsonwittwer are you able to give us a little more on your plans/ideas/etc for this? Thanks again for everything

mibock commented 11 months ago

Hi @nelsonwittwer - you mention above that you internally have an OpenAPI schema that is used to generate the REST Resources (among others). We are currently working to support Shopify in our Data Integration tool (www.rapidionline.com). I have been looking high and low for a schema that describes the REST API Resources, but found nothing until now. A schema like this would allow us to stay current with the updates to the API that you make (without having to reverse engineer and build it from e.g. this repo). Can we somehow get access to this OpenAPI schema ?

SudhamsuAtCleo commented 1 month ago

Hi @mibock We require the OpenAPI schema as well - did you find a solution? (If you don't mind sharing it).

@nelsonwittwer

These files are all generated from an OpenAPI schema that, ironically, are not yet open to the public

Are they still not open to the public? It'll be great if the latest OpenAPI schemas can be released to the public to avoid a lot of reverse engineering.