{"id":13878548,"url":"https://github.com/ScreenStaring/shopify_api-graphql-tiny","last_synced_at":"2025-07-16T14:32:33.487Z","repository":{"id":56895384,"uuid":"441355029","full_name":"ScreenStaring/shopify_api-graphql-tiny","owner":"ScreenStaring","description":"Lightweight, no-nonsense, Shopify GraphQL Admin API client with built-in pagination and retry.","archived":false,"fork":false,"pushed_at":"2023-02-13T01:27:42.000Z","size":33,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-03-26T00:39:20.100Z","etag":null,"topics":["graphql","graphql-pagination","ruby","shopify","shopify-api"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ScreenStaring.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-24T03:25:07.000Z","updated_at":"2024-08-06T08:47:09.807Z","dependencies_parsed_at":"2024-08-06T08:47:03.901Z","dependency_job_id":"15c8c8ae-4daa-4a8e-930b-01fa6da6e845","html_url":"https://github.com/ScreenStaring/shopify_api-graphql-tiny","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScreenStaring%2Fshopify_api-graphql-tiny","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScreenStaring%2Fshopify_api-graphql-tiny/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScreenStaring%2Fshopify_api-graphql-tiny/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScreenStaring%2Fshopify_api-graphql-tiny/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ScreenStaring","download_url":"https://codeload.github.com/ScreenStaring/shopify_api-graphql-tiny/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226138849,"owners_count":17579496,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphql","graphql-pagination","ruby","shopify","shopify-api"],"created_at":"2024-08-06T08:01:52.790Z","updated_at":"2025-07-16T14:32:33.457Z","avatar_url":"https://github.com/ScreenStaring.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# ShopifyAPI::GraphQL::Tiny\n\nLightweight, no-nonsense, Shopify GraphQL Admin API client with built-in pagination and retry.\n\n[![CI](https://github.com/ScreenStaring/shopify_api-graphql-tiny/actions/workflows/ci.yml/badge.svg)](https://github.com/ScreenStaring/shopify_api-graphql-tiny/actions)\n\n## Installation\n\nAdd this line to your application's `Gemfile`:\n\n```ruby\ngem \"shopify_api-graphql-tiny\"\n```\n\nAnd then execute:\n\n```sh\nbundle\n```\n\nOr install it yourself as:\n\n```sh\ngem install shopify_api-graphql-tiny\n```\n\n## Usage\n\n```rb\nrequire \"shopify_api/graphql/tiny\"\n\ngql = ShopifyAPI::GraphQL::Tiny.new(\"my-shop\", token)\n\n# Automatically retried\nresult = gql.execute(\u003c\u003c-GQL, :id =\u003e \"gid://shopify/Customer/1283599123\")\n  query findCustomer($id: ID!) {\n    customer(id: $id) {\n      id\n      tags\n      metafields(first: 10 namespace: \"foo\") {\n        edges {\n          node {\n            id\n            key\n            value\n          }\n        }\n      }\n    }\n  }\nGQL\n\ncustomer = result[\"data\"][\"customer\"]\np customer[\"tags\"]\np customer.dig(\"metafields\", \"edges\", 0, \"node\")[\"value\"]\n\nupdates = { :id =\u003e customer[\"id\"], :tags =\u003e customer[\"tags\"] + %w[foo bar] }\n\n# Automatically retried as well\nresult = gql.execute(\u003c\u003c-GQL, :input =\u003e updates)\n  mutation customerUpdate($input: CustomerInput!) {\n    customerUpdate(input: $input) {\n      customer {\n        id\n      }\n      userErrors {\n        field\n        message\n      }\n    }\n  }\nGQL\n\np result.dig(\"data\", \"customerUpdate\", \"userErrors\")\n```\n\n### Pagination\n\nIn addition to built-in request retry `ShopifyAPI::GraphQL::Tiny` also builds in support for pagination.\n\nUsing pagination requires you to include [the Shopify `PageInfo` object](https://shopify.dev/api/admin-graphql/2022-10/objects/PageInfo)\nin your queries and wrap them in a function that accepts a page/cursor argument.\n\nThe pager's `#execute` is like the non-paginated `#execute` method and accepts additional, non-pagination query arguments:\n\n```rb\ngql = ShopifyAPI::GraphQL::Tiny.new(\"my-shop\", token)\npager = gql.paginate\npager.execute(query, :foo =\u003e 123)\n```\n\nAnd it accepts a block which will be passed each page returned by the query:\n\n```rb\npager.execute(query, :foo =\u003e 123) do |page|\n  # do something with each page\nend\n```\n\n#### `after` Pagination\n\nTo use `after` pagination, i.e., to paginate forward, your query must:\n\n- Make the page/cursor argument optional\n- Include `PageInfo`'s `hasNextPage` and `endCursor` fields\n\nFor example:\n\n```rb\nFIND_ORDERS = \u003c\u003c-GQL\n  query findOrders($after: String) {\n    orders(first: 10 after: $after) {\n      pageInfo {\n        hasNextPage\n        endCursor\n      }\n      edges {\n        node {\n          id\n          email\n        }\n      }\n    }\n  }\nGQL\n\npager = gql.paginate  # This is the same as gql.paginate(:after)\npager.execute(FIND_ORDERS) do |page|\n  orders = page.dig(\"data\", \"orders\", \"edges\")\n  orders.each do |order|\n    # ...\n  end\nend\n```\n\nBy default it is assumed your GraphQL query uses a variable named `$after`. You can specify a different name using the `:variable`\noption:\n\n```rb\npager = gql.paginate(:after, :variable =\u003e \"yourVariable\")\n```\n\n#### `before` Pagination\n\nTo use `before` pagination, i.e. to paginate backward, your query must:\n\n- Make the page/cursor argument **required**\n- Include the `PageInfo`'s `hasPreviousPage` and `startCursor` fields\n- Specify the `:before` argument to `#paginate`\n\nFor example:\n\n```rb\nFIND_ORDERS = \u003c\u003c-GQL\n  query findOrders($before: String) {\n    orders(last: 10 before: $before) {\n      pageInfo {\n        hasPreviousPage\n        startCursor\n      }\n      edges {\n        node {\n          id\n          email\n        }\n      }\n    }\n  }\nGQL\n\npager = gql.paginate(:before)\npager.execute(FIND_ORDERS) do |page|\n  # ...\nend\n```\n\nBy default it is assumed your GraphQL query uses a variable named `$before`. You can specify a different name using the `:variable`\noption:\n\n```rb\npager = gql.paginate(:before, :variable =\u003e \"yourVariable\")\n```\n\n#### Response Pagination Data\n\nBy default `ShopifyAPI::GraphQL::Tiny` will use the first `pageInfo` block with a next or previous page it finds\nin the GraphQL response. If necessary you can specify an explicit location for the `pageInfo` block:\n\n```rb\npager = gql.paginate(:after =\u003e %w[some path to it])\npager.execute(query) { |page| }\n\npager = gql.paginate(:after =\u003e -\u003e(data) { data.dig(\"some\", \"path\", \"to\", \"it\") })\npager.execute(query) { |page| }\n```\n\nThe `\"data\"` and `\"pageInfo\"` keys are automatically added if not provided.\n\n### Automatically Retrying Failed Requests\n\nSee [the docs](https://rubydoc.info/gems/shopify_api-graphql-tiny) for more information.\n\n## Testing\n\n`cp env.template .env` and fill-in `.env` with the missing values. This requires a Shopify store.\n\n## See Also\n\n- [Shopify Dev Tools](https://github.com/ScreenStaring/shopify-dev-tools) - Command-line program to assist with the development and/or maintenance of Shopify apps and stores\n- [Shopify ID Export](https://github.com/ScreenStaring/shopify_id_export/) Dump Shopify product and variant IDs —along with other identifiers— to a CSV or JSON file\n- [ShopifyAPIRetry](https://github.com/ScreenStaring/shopify_api_retry) - Retry a ShopifyAPI request if rate-limited or other errors occur (REST and GraphQL APIs)\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n---\n\nMade by [ScreenStaring](http://screenstaring.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FScreenStaring%2Fshopify_api-graphql-tiny","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FScreenStaring%2Fshopify_api-graphql-tiny","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FScreenStaring%2Fshopify_api-graphql-tiny/lists"}