shopify_graphql 1.1.1 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34fd94e0b5a246e1998c79a0e860c39e7f6fe842f2f8df3717955b9d4a7986b1
4
- data.tar.gz: da89901175f71017f6ba9e0b94da554f760c061a26b87674d1c09726c947a1ef
3
+ metadata.gz: d369baa765d2026c9ccc02017bb2b6a490b202ad30b6a789eec1f0d2dfc313c6
4
+ data.tar.gz: c4054cbd4b4c5432e53c810374e1ec1acd4b64c0af6a4059858946aa0795056c
5
5
  SHA512:
6
- metadata.gz: 6b489b44869cdd2a43fd2ab4682ed27766edf1aa998cd398c6c65e0a958be5612c2a2e3675202e6264011f9d3a38bd02e6fbd861f7d0e641321fbe4c84b30576
7
- data.tar.gz: 2d85617836581b983afe601da73336a32536c5c198181de0c01ce2560d46164e708856de748597b0391d00dcc5144014141335d2c38ed3c6ba8cb61ce7869a77
6
+ metadata.gz: 6d2b5610659195319c502304bd1b0a7f741d46da3c4342b1afd0224a39a421463a39b2e0c7132c67aa90c20aa114a7baf9a0bda4611ccfdcdc30bf6a503b038d
7
+ data.tar.gz: f8f2ee0d61394d5fcd20ab25c75d87eb404b545685da95cdbd65f4cecc477b63ac8c226b0acaf2be57f9cc6c6be848ca725846ef40aefea15eb12425e958b67f
data/README.md CHANGED
@@ -384,24 +384,7 @@ class GetProducts
384
384
  QUERY = <<~GRAPHQL
385
385
  #{ProductFields::FRAGMENT}
386
386
 
387
- query {
388
- products(first: #{LIMIT}) {
389
- edges {
390
- node {
391
- ... ProductFields
392
- }
393
- }
394
- pageInfo {
395
- hasNextPage
396
- endCursor
397
- }
398
- }
399
- }
400
- GRAPHQL
401
- QUERY_WITH_CURSOR = <<~GRAPHQL
402
- #{ProductFields::FRAGMENT}
403
-
404
- query($cursor: String!) {
387
+ query($cursor: String) {
405
388
  products(first: #{LIMIT}, after: $cursor) {
406
389
  edges {
407
390
  node {
@@ -421,7 +404,7 @@ class GetProducts
421
404
  data = parse_data(response.data.products.edges)
422
405
 
423
406
  while response.data.products.pageInfo.hasNextPage
424
- response = execute(QUERY_WITH_CURSOR, cursor: response.data.products.pageInfo.endCursor)
407
+ response = execute(QUERY, cursor: response.data.products.pageInfo.endCursor)
425
408
  data += parse_data(response.data.products.edges)
426
409
  end
427
410
 
@@ -492,24 +475,7 @@ class GetProducts
492
475
  QUERY = <<~GRAPHQL
493
476
  #{ProductFields::FRAGMENT}
494
477
 
495
- query {
496
- products(first: #{LIMIT}) {
497
- edges {
498
- node {
499
- ... ProductFields
500
- }
501
- }
502
- pageInfo {
503
- hasNextPage
504
- endCursor
505
- }
506
- }
507
- }
508
- GRAPHQL
509
- QUERY_WITH_CURSOR = <<~GRAPHQL
510
- #{ProductFields::FRAGMENT}
511
-
512
- query($cursor: String!) {
478
+ query($cursor: String) {
513
479
  products(first: #{LIMIT}, after: $cursor) {
514
480
  edges {
515
481
  node {
@@ -531,7 +497,7 @@ class GetProducts
531
497
  end
532
498
 
533
499
  while response.data.products.pageInfo.hasNextPage
534
- response = execute(QUERY_WITH_CURSOR, cursor: response.data.products.pageInfo.endCursor)
500
+ response = execute(QUERY, cursor: response.data.products.pageInfo.endCursor)
535
501
  response.data.products.edges.each do |edge|
536
502
  block.call ProductFields.parse(edge.node)
537
503
  end
@@ -567,30 +533,7 @@ class GetCollectionsWithProducts
567
533
  COLLECTIONS_LIMIT = 1
568
534
  PRODUCTS_LIMIT = 25
569
535
  QUERY = <<~GRAPHQL
570
- query {
571
- collections(first: #{COLLECTIONS_LIMIT}) {
572
- edges {
573
- node {
574
- id
575
- title
576
- products(first: #{PRODUCTS_LIMIT}) {
577
- edges {
578
- node {
579
- id
580
- }
581
- }
582
- }
583
- }
584
- }
585
- pageInfo {
586
- hasNextPage
587
- endCursor
588
- }
589
- }
590
- }
591
- GRAPHQL
592
- QUERY_WITH_CURSOR = <<~GRAPHQL
593
- query ($cursor: String!) {
536
+ query ($cursor: String) {
594
537
  collections(first: #{COLLECTIONS_LIMIT}, after: $cursor) {
595
538
  edges {
596
539
  node {
@@ -618,7 +561,7 @@ class GetCollectionsWithProducts
618
561
  data = parse_data(response.data.collections.edges)
619
562
 
620
563
  while response.data.collections.pageInfo.hasNextPage
621
- response = execute(QUERY_WITH_CURSOR, cursor: response.data.collections.pageInfo.endCursor)
564
+ response = execute(QUERY, cursor: response.data.collections.pageInfo.endCursor)
622
565
  data += parse_data(response.data.collections.edges)
623
566
  end
624
567
 
@@ -4,6 +4,8 @@ module ShopifyGraphql
4
4
  ShopifyGraphql.configuration.webhooks_manager_queue_name
5
5
  end
6
6
 
7
+ retry_on ShopifyGraphql::TooManyRequests
8
+
7
9
  def perform(shop_domain:, shop_token:)
8
10
  webhooks = ShopifyGraphql.configuration.webhooks
9
11
 
@@ -22,6 +22,10 @@ module ShopifyGraphql
22
22
  extensions&.cost&.throttleStatus&.restoreRate
23
23
  end
24
24
 
25
+ def query_cost
26
+ extensions&.cost&.actualQueryCost
27
+ end
28
+
25
29
  def points_maxed?(threshold: 0)
26
30
  points_left < threshold
27
31
  end
@@ -1,3 +1,3 @@
1
1
  module ShopifyGraphql
2
- VERSION = "1.1.1"
2
+ VERSION = "1.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Platonov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-16 00:00:00.000000000 Z
11
+ date: 2023-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails