shopify_graphql 1.1.0 → 1.2.0

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: ae1e8d2f4d571b2b213c2a16b4119aa5067f4eaca441db0893b80cff71b0bde7
4
- data.tar.gz: 7246d23c32915ef20166202cf920f811631dd9a47c922bc207eeba7706d85f44
3
+ metadata.gz: '028218d246ffa0ba8a2e65131c5abf7f9b70f1030818d41ed17e07dafd4ae273'
4
+ data.tar.gz: 703a8d3c95b26c26ca500016aa3f68057a6e25cd9afef55d89b5e9aaea17d61f
5
5
  SHA512:
6
- metadata.gz: 744a08c3749b3083d5a3f7214a639102a2fa6a6a817bc416e5ae7688064f797a182555ab0965abaca75353a82464c2e124274585216f3df75665a8511ea37fb6
7
- data.tar.gz: aad5f84d8c809cb208d455d4cbf1d25024f254febb3582469b8a65886d357a247f23f94821fc93333767d72bff6dc5cecde57bb87173ae580d8a22bcdd496d58
6
+ metadata.gz: 78cbd2465f2803330e6427539a9ca7dccdccdeab7d17bf9556f1d34e3b1dc0bd6a29d0fd6bbfb2b08276e2e2cf49957f2b420745bfa8dddaf090494e194c54dd
7
+ data.tar.gz: 947365b6f1c8042ee08071dc548506875c9810b1337b2b7ebc0114365e238d2ad046e9f7604b023a5baf26382db09e002cc77a3ff22e80643abfa7060738872c
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
 
@@ -12,7 +12,7 @@ module ShopifyGraphql
12
12
  rescue JSON::ParserError => e
13
13
  raise ServerError.new(e, "Invalid JSON response")
14
14
  rescue Errno::ECONNRESET, Errno::EPIPE, Net::ReadTimeout, Net::OpenTimeout, OpenSSL::SSL::SSLError => e
15
- raise ConnectionError.new(e, "Network error")
15
+ raise ServerError.new(e, "Network error")
16
16
  end
17
17
 
18
18
  def parsed_body(response)
@@ -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.0"
2
+ VERSION = "1.2.0"
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.0
4
+ version: 1.2.0
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-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails