solidus_graphql_api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (253) hide show
  1. checksums.yaml +7 -0
  2. data/.circleci/config.yml +93 -0
  3. data/.gem_release.yml +5 -0
  4. data/.github/stale.yml +17 -0
  5. data/.gitignore +20 -0
  6. data/.rspec +2 -0
  7. data/.rubocop.yml +62 -0
  8. data/CHANGELOG.md +0 -0
  9. data/CONTRIBUTING.md +57 -0
  10. data/Gemfile +33 -0
  11. data/LICENSE +26 -0
  12. data/LICENSE.md +26 -0
  13. data/README.md +245 -0
  14. data/Rakefile +43 -0
  15. data/app/controllers/spree/graphql_controller.rb +49 -0
  16. data/bin/console +17 -0
  17. data/bin/rails +9 -0
  18. data/bin/rails-engine +16 -0
  19. data/bin/rails-sandbox +18 -0
  20. data/bin/rake +8 -0
  21. data/bin/sandbox +84 -0
  22. data/bin/setup +8 -0
  23. data/config/locales/en.yml +6 -0
  24. data/config/routes.rb +5 -0
  25. data/lib/generators/solidus_graphql_api/install/install_generator.rb +8 -0
  26. data/lib/solidus_graphql_api.rb +11 -0
  27. data/lib/solidus_graphql_api/batch_loader.rb +114 -0
  28. data/lib/solidus_graphql_api/batch_loader/belongs_to.rb +30 -0
  29. data/lib/solidus_graphql_api/batch_loader/has_many.rb +24 -0
  30. data/lib/solidus_graphql_api/batch_loader/has_many_through.rb +42 -0
  31. data/lib/solidus_graphql_api/batch_loader/has_one.rb +22 -0
  32. data/lib/solidus_graphql_api/configuration.rb +19 -0
  33. data/lib/solidus_graphql_api/context.rb +76 -0
  34. data/lib/solidus_graphql_api/engine.rb +25 -0
  35. data/lib/solidus_graphql_api/factories.rb +11 -0
  36. data/lib/solidus_graphql_api/factories/address_factory.rb +8 -0
  37. data/lib/solidus_graphql_api/factories/country_factory.rb +12 -0
  38. data/lib/solidus_graphql_api/factories/store_factory.rb +16 -0
  39. data/lib/solidus_graphql_api/factories/taxonomy_factory.rb +26 -0
  40. data/lib/solidus_graphql_api/mutations/.keep +0 -0
  41. data/lib/solidus_graphql_api/mutations/base_mutation.rb +45 -0
  42. data/lib/solidus_graphql_api/mutations/checkout/add_addresses_to_checkout.rb +41 -0
  43. data/lib/solidus_graphql_api/mutations/checkout/add_payment_to_checkout.rb +45 -0
  44. data/lib/solidus_graphql_api/mutations/checkout/add_to_cart.rb +30 -0
  45. data/lib/solidus_graphql_api/mutations/checkout/advance_checkout.rb +27 -0
  46. data/lib/solidus_graphql_api/mutations/checkout/apply_coupon_code.rb +32 -0
  47. data/lib/solidus_graphql_api/mutations/checkout/complete_checkout.rb +31 -0
  48. data/lib/solidus_graphql_api/mutations/checkout/create_order.rb +27 -0
  49. data/lib/solidus_graphql_api/mutations/checkout/empty_cart.rb +29 -0
  50. data/lib/solidus_graphql_api/mutations/checkout/next_checkout_state.rb +27 -0
  51. data/lib/solidus_graphql_api/mutations/checkout/remove_from_cart.rb +33 -0
  52. data/lib/solidus_graphql_api/mutations/checkout/select_shipping_rate.rb +40 -0
  53. data/lib/solidus_graphql_api/mutations/checkout/set_order_email.rb +29 -0
  54. data/lib/solidus_graphql_api/mutations/checkout/update_cart_quantity.rb +41 -0
  55. data/lib/solidus_graphql_api/mutations/user/mark_default_address.rb +31 -0
  56. data/lib/solidus_graphql_api/mutations/user/remove_from_address_book.rb +25 -0
  57. data/lib/solidus_graphql_api/mutations/user/save_in_address_book.rb +30 -0
  58. data/lib/solidus_graphql_api/queries/address/country_query.rb +19 -0
  59. data/lib/solidus_graphql_api/queries/address/state_query.rb +19 -0
  60. data/lib/solidus_graphql_api/queries/completed_orders_query.rb +19 -0
  61. data/lib/solidus_graphql_api/queries/countries_query.rb +11 -0
  62. data/lib/solidus_graphql_api/queries/country/states_query.rb +19 -0
  63. data/lib/solidus_graphql_api/queries/line_item/variant_query.rb +19 -0
  64. data/lib/solidus_graphql_api/queries/option_type/option_values_query.rb +19 -0
  65. data/lib/solidus_graphql_api/queries/order/adjustments_query.rb +19 -0
  66. data/lib/solidus_graphql_api/queries/order/billing_address_query.rb +19 -0
  67. data/lib/solidus_graphql_api/queries/order/line_items_query.rb +19 -0
  68. data/lib/solidus_graphql_api/queries/order/payments_query.rb +19 -0
  69. data/lib/solidus_graphql_api/queries/order/shipments_query.rb +19 -0
  70. data/lib/solidus_graphql_api/queries/order/shipping_address_query.rb +19 -0
  71. data/lib/solidus_graphql_api/queries/product/master_variant_query.rb +19 -0
  72. data/lib/solidus_graphql_api/queries/product/option_types_query.rb +19 -0
  73. data/lib/solidus_graphql_api/queries/product/product_properties_query.rb +19 -0
  74. data/lib/solidus_graphql_api/queries/product/variants_query.rb +19 -0
  75. data/lib/solidus_graphql_api/queries/product_by_slug_query.rb +11 -0
  76. data/lib/solidus_graphql_api/queries/product_property/property_query.rb +19 -0
  77. data/lib/solidus_graphql_api/queries/products_query.rb +29 -0
  78. data/lib/solidus_graphql_api/queries/shipment/shipping_rates_query.rb +19 -0
  79. data/lib/solidus_graphql_api/queries/taxon/children_query.rb +19 -0
  80. data/lib/solidus_graphql_api/queries/taxon/parent_taxon_query.rb +19 -0
  81. data/lib/solidus_graphql_api/queries/taxonomies_query.rb +11 -0
  82. data/lib/solidus_graphql_api/queries/taxonomy/root_taxon_query.rb +19 -0
  83. data/lib/solidus_graphql_api/queries/taxonomy/taxons_query.rb +19 -0
  84. data/lib/solidus_graphql_api/queries/variant/default_price_query.rb +19 -0
  85. data/lib/solidus_graphql_api/queries/variant/images_query.rb +19 -0
  86. data/lib/solidus_graphql_api/queries/variant/option_values_query.rb +19 -0
  87. data/lib/solidus_graphql_api/queries/variant/prices_query.rb +19 -0
  88. data/lib/solidus_graphql_api/schema.rb +40 -0
  89. data/lib/solidus_graphql_api/types/.keep +0 -0
  90. data/lib/solidus_graphql_api/types/address.rb +32 -0
  91. data/lib/solidus_graphql_api/types/base/argument.rb +10 -0
  92. data/lib/solidus_graphql_api/types/base/enum.rb +10 -0
  93. data/lib/solidus_graphql_api/types/base/field.rb +13 -0
  94. data/lib/solidus_graphql_api/types/base/input_object.rb +10 -0
  95. data/lib/solidus_graphql_api/types/base/interface.rb +11 -0
  96. data/lib/solidus_graphql_api/types/base/object.rb +25 -0
  97. data/lib/solidus_graphql_api/types/base/relay_node.rb +13 -0
  98. data/lib/solidus_graphql_api/types/base/scalar.rb +10 -0
  99. data/lib/solidus_graphql_api/types/base/union.rb +10 -0
  100. data/lib/solidus_graphql_api/types/country.rb +23 -0
  101. data/lib/solidus_graphql_api/types/credit_card.rb +18 -0
  102. data/lib/solidus_graphql_api/types/currency.rb +14 -0
  103. data/lib/solidus_graphql_api/types/image.rb +27 -0
  104. data/lib/solidus_graphql_api/types/input_objects/address_input.rb +24 -0
  105. data/lib/solidus_graphql_api/types/input_objects/products_query_input.rb +15 -0
  106. data/lib/solidus_graphql_api/types/interfaces/adjustment.rb +32 -0
  107. data/lib/solidus_graphql_api/types/interfaces/payment_source.rb +19 -0
  108. data/lib/solidus_graphql_api/types/json.rb +63 -0
  109. data/lib/solidus_graphql_api/types/line_item.rb +26 -0
  110. data/lib/solidus_graphql_api/types/manifest_item.rb +12 -0
  111. data/lib/solidus_graphql_api/types/mutation.rb +24 -0
  112. data/lib/solidus_graphql_api/types/option_type.rb +22 -0
  113. data/lib/solidus_graphql_api/types/option_value.rb +15 -0
  114. data/lib/solidus_graphql_api/types/order.rb +63 -0
  115. data/lib/solidus_graphql_api/types/payment.rb +15 -0
  116. data/lib/solidus_graphql_api/types/payment_method.rb +15 -0
  117. data/lib/solidus_graphql_api/types/price.rb +21 -0
  118. data/lib/solidus_graphql_api/types/product.rb +38 -0
  119. data/lib/solidus_graphql_api/types/product_property.rb +19 -0
  120. data/lib/solidus_graphql_api/types/promotion_adjustment.rb +17 -0
  121. data/lib/solidus_graphql_api/types/property.rb +14 -0
  122. data/lib/solidus_graphql_api/types/query.rb +84 -0
  123. data/lib/solidus_graphql_api/types/shipment.rb +23 -0
  124. data/lib/solidus_graphql_api/types/shipping_rate.rb +15 -0
  125. data/lib/solidus_graphql_api/types/state.rb +14 -0
  126. data/lib/solidus_graphql_api/types/store.rb +27 -0
  127. data/lib/solidus_graphql_api/types/tax_adjustment.rb +11 -0
  128. data/lib/solidus_graphql_api/types/taxon.rb +33 -0
  129. data/lib/solidus_graphql_api/types/taxonomy.rb +23 -0
  130. data/lib/solidus_graphql_api/types/user.rb +23 -0
  131. data/lib/solidus_graphql_api/types/user_error.rb +12 -0
  132. data/lib/solidus_graphql_api/types/variant.rb +39 -0
  133. data/lib/solidus_graphql_api/types/wallet_payment_source.rb +14 -0
  134. data/lib/solidus_graphql_api/version.rb +5 -0
  135. data/schema.graphql +2070 -0
  136. data/solidus_graphql_api.gemspec +43 -0
  137. data/spec/integration/mutations/add_to_cart_spec.rb +67 -0
  138. data/spec/integration/mutations/checkout/add_addresses_to_checkout_spec.rb +115 -0
  139. data/spec/integration/mutations/checkout/add_payment_to_checkout_spec.rb +87 -0
  140. data/spec/integration/mutations/checkout/advance_checkout_spec.rb +71 -0
  141. data/spec/integration/mutations/checkout/apply_coupon_code_spec.rb +76 -0
  142. data/spec/integration/mutations/checkout/complete_checkout_spec.rb +56 -0
  143. data/spec/integration/mutations/checkout/next_checkout_state_spec.rb +69 -0
  144. data/spec/integration/mutations/checkout/select_shipping_rate_spec.rb +89 -0
  145. data/spec/integration/mutations/create_order_spec.rb +55 -0
  146. data/spec/integration/mutations/empty_cart_spec.rb +58 -0
  147. data/spec/integration/mutations/mark_default_address_spec.rb +33 -0
  148. data/spec/integration/mutations/remove_from_address_book_spec.rb +48 -0
  149. data/spec/integration/mutations/remove_from_cart_spec.rb +65 -0
  150. data/spec/integration/mutations/save_in_address_book_spec.rb +90 -0
  151. data/spec/integration/mutations/set_order_email_spec.rb +61 -0
  152. data/spec/integration/mutations/update_cart_quantity_spec.rb +68 -0
  153. data/spec/integration/queries/completed_orders_spec.rb +158 -0
  154. data/spec/integration/queries/countries_spec.rb +18 -0
  155. data/spec/integration/queries/current_order_spec.rb +15 -0
  156. data/spec/integration/queries/current_store_spec.rb +15 -0
  157. data/spec/integration/queries/current_user_spec.rb +43 -0
  158. data/spec/integration/queries/product_by_slug_spec.rb +42 -0
  159. data/spec/integration/queries/products_spec.rb +40 -0
  160. data/spec/integration/queries/taxonomies_spec.rb +22 -0
  161. data/spec/lib/solidus_graphql_api/batch_loader/belongs_to_spec.rb +67 -0
  162. data/spec/lib/solidus_graphql_api/batch_loader/has_many_spec.rb +38 -0
  163. data/spec/lib/solidus_graphql_api/batch_loader/has_many_through_spec.rb +47 -0
  164. data/spec/lib/solidus_graphql_api/batch_loader/has_one_spec.rb +38 -0
  165. data/spec/lib/solidus_graphql_api/context_spec.rb +236 -0
  166. data/spec/lib/solidus_graphql_api/queries/address/country_query_spec.rb +13 -0
  167. data/spec/lib/solidus_graphql_api/queries/address/state_query_spec.rb +13 -0
  168. data/spec/lib/solidus_graphql_api/queries/completed_orders_query_spec.rb +12 -0
  169. data/spec/lib/solidus_graphql_api/queries/countries_query_spec.rb +11 -0
  170. data/spec/lib/solidus_graphql_api/queries/country/states_query_spec.rb +11 -0
  171. data/spec/lib/solidus_graphql_api/queries/line_item/variant_query_spec.rb +9 -0
  172. data/spec/lib/solidus_graphql_api/queries/option_type/option_values_query_spec.rb +11 -0
  173. data/spec/lib/solidus_graphql_api/queries/order/adjustments_query_spec.rb +10 -0
  174. data/spec/lib/solidus_graphql_api/queries/order/billing_address_query_spec.rb +11 -0
  175. data/spec/lib/solidus_graphql_api/queries/order/line_items_query_spec.rb +9 -0
  176. data/spec/lib/solidus_graphql_api/queries/order/payments_query_spec.rb +9 -0
  177. data/spec/lib/solidus_graphql_api/queries/order/shipments_query_spec.rb +18 -0
  178. data/spec/lib/solidus_graphql_api/queries/order/shipping_address_query_spec.rb +11 -0
  179. data/spec/lib/solidus_graphql_api/queries/product/master_variant_query_spec.rb +11 -0
  180. data/spec/lib/solidus_graphql_api/queries/product/option_types_query_spec.rb +11 -0
  181. data/spec/lib/solidus_graphql_api/queries/product/product_properties_query_spec.rb +11 -0
  182. data/spec/lib/solidus_graphql_api/queries/product/variants_query_spec.rb +11 -0
  183. data/spec/lib/solidus_graphql_api/queries/product_by_slug_query_spec.rb +13 -0
  184. data/spec/lib/solidus_graphql_api/queries/product_property/property_query_spec.rb +11 -0
  185. data/spec/lib/solidus_graphql_api/queries/products_query_spec.rb +49 -0
  186. data/spec/lib/solidus_graphql_api/queries/shipment/shipping_rates_query_spec.rb +18 -0
  187. data/spec/lib/solidus_graphql_api/queries/taxon/children_query_spec.rb +11 -0
  188. data/spec/lib/solidus_graphql_api/queries/taxon/parent_taxon_query_spec.rb +10 -0
  189. data/spec/lib/solidus_graphql_api/queries/taxonomies_query_spec.rb +11 -0
  190. data/spec/lib/solidus_graphql_api/queries/taxonomy/root_taxon_query_spec.rb +10 -0
  191. data/spec/lib/solidus_graphql_api/queries/taxonomy/taxons_query_spec.rb +11 -0
  192. data/spec/lib/solidus_graphql_api/queries/variant/default_price_query_spec.rb +9 -0
  193. data/spec/lib/solidus_graphql_api/queries/variant/images_query_spec.rb +11 -0
  194. data/spec/lib/solidus_graphql_api/queries/variant/option_values_query_spec.rb +11 -0
  195. data/spec/lib/solidus_graphql_api/queries/variant/prices_query_spec.rb +13 -0
  196. data/spec/lib/solidus_graphql_api/schema_spec.rb +80 -0
  197. data/spec/lib/solidus_graphql_api/types/base/object_spec.rb +29 -0
  198. data/spec/lib/solidus_graphql_api/types/json_spec.rb +115 -0
  199. data/spec/lib/solidus_graphql_api/types/option_type_spec.rb +7 -0
  200. data/spec/lib/solidus_graphql_api/types/product_property_spec.rb +22 -0
  201. data/spec/lib/solidus_graphql_api/types/product_spec.rb +56 -0
  202. data/spec/lib/solidus_graphql_api/types/query_spec.rb +33 -0
  203. data/spec/lib/solidus_graphql_api/types/variant_spec.rb +58 -0
  204. data/spec/requests/spree/graphql_controller_spec.rb +17 -0
  205. data/spec/spec_helper.rb +62 -0
  206. data/spec/support/expected_schema.graphql +2070 -0
  207. data/spec/support/graphql/mutations/add_addresses_to_checkout.gql +19 -0
  208. data/spec/support/graphql/mutations/add_payment_to_checkout.gql +13 -0
  209. data/spec/support/graphql/mutations/add_to_cart.gql +21 -0
  210. data/spec/support/graphql/mutations/advance_checkout.gql +13 -0
  211. data/spec/support/graphql/mutations/apply_coupon_code.gql +13 -0
  212. data/spec/support/graphql/mutations/complete_checkout.gql +13 -0
  213. data/spec/support/graphql/mutations/create_order.gql +11 -0
  214. data/spec/support/graphql/mutations/empty_cart.gql +17 -0
  215. data/spec/support/graphql/mutations/mark_default_address.gql +9 -0
  216. data/spec/support/graphql/mutations/next_checkout_state.gql +13 -0
  217. data/spec/support/graphql/mutations/remove_from_address_book.gql +14 -0
  218. data/spec/support/graphql/mutations/remove_from_cart.gql +17 -0
  219. data/spec/support/graphql/mutations/save_in_address_book.gql +57 -0
  220. data/spec/support/graphql/mutations/select_shipping_rate.gql +23 -0
  221. data/spec/support/graphql/mutations/set_order_email.gql +13 -0
  222. data/spec/support/graphql/mutations/update_cart_quantity.gql +18 -0
  223. data/spec/support/graphql/queries/completed_orders.gql +29 -0
  224. data/spec/support/graphql/queries/completed_orders/adjustments.gql +24 -0
  225. data/spec/support/graphql/queries/completed_orders/available_payment_methods.gql +15 -0
  226. data/spec/support/graphql/queries/completed_orders/billing_address.gql +40 -0
  227. data/spec/support/graphql/queries/completed_orders/line_items.gql +23 -0
  228. data/spec/support/graphql/queries/completed_orders/payments.gql +23 -0
  229. data/spec/support/graphql/queries/completed_orders/shipping_address.gql +40 -0
  230. data/spec/support/graphql/queries/countries.gql +24 -0
  231. data/spec/support/graphql/queries/current_order.gql +32 -0
  232. data/spec/support/graphql/queries/current_store.gql +24 -0
  233. data/spec/support/graphql/queries/current_user.gql +197 -0
  234. data/spec/support/graphql/queries/product_by_slug.gql +106 -0
  235. data/spec/support/graphql/queries/products.gql +7 -0
  236. data/spec/support/graphql/queries/taxonomies.gql +81 -0
  237. data/spec/support/graphql/responses/completed_orders.json.erb +58 -0
  238. data/spec/support/graphql/responses/completed_orders/adjustments.json.erb +34 -0
  239. data/spec/support/graphql/responses/completed_orders/available_payment_methods.json.erb +29 -0
  240. data/spec/support/graphql/responses/completed_orders/billing_address.json.erb +78 -0
  241. data/spec/support/graphql/responses/completed_orders/line_items.json.erb +43 -0
  242. data/spec/support/graphql/responses/completed_orders/payments.json.erb +27 -0
  243. data/spec/support/graphql/responses/completed_orders/shipping_address.json.erb +78 -0
  244. data/spec/support/graphql/responses/countries.json.erb +51 -0
  245. data/spec/support/graphql/responses/current_order.json.erb +36 -0
  246. data/spec/support/graphql/responses/current_store.json.erb +34 -0
  247. data/spec/support/graphql/responses/current_user.json.erb +232 -0
  248. data/spec/support/graphql/responses/product_by_slug.json.erb +123 -0
  249. data/spec/support/graphql/responses/taxonomies.json.erb +145 -0
  250. data/spec/support/helpers/graphql.rb +43 -0
  251. data/spec/support/matchers/graphql.rb +35 -0
  252. data/spec/support/shared_contexts/graphql_query_subject.rb +21 -0
  253. metadata +572 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e13d165667b997910b872578daab0555697266f687273c44591815ad4e25fb54
4
+ data.tar.gz: 83e8894cdd383331705701f8e69aa97aefeded8d42d07c4cc88f29fcd03b0ac1
5
+ SHA512:
6
+ metadata.gz: e83c25b7120e61b3d5c7e20773159c87b66fc01f2439d4d829c6d19b3abf143f21af16581b75fe6e6561540963aca1a00493dcbf598d5145c128e384bae639eb
7
+ data.tar.gz: 43e1ce11f2e47eb48d4d9b7157a69f1c15a9a0d67871cde22bfeb93b72f84205ecb721b7484ea27ea85a3f2a02c099f15693f85ac65ba0c5e51afb6d3b5b68dd
@@ -0,0 +1,93 @@
1
+ version: 2.1
2
+
3
+ orbs:
4
+ # Always take the latest version of the orb, this allows us to
5
+ # run specs against Solidus supported versions only without the need
6
+ # to change this configuration every time a Solidus version is released
7
+ # or goes EOL.
8
+ solidusio_extensions: solidusio/extensions@volatile
9
+
10
+ commands:
11
+ bundle:
12
+ description: 'Install and cache gems'
13
+ steps:
14
+ - restore_cache:
15
+ keys:
16
+ - v1-bundle-{{ checksum "solidus_graphql_api.gemspec" }}-{{ checksum "Gemfile" }}
17
+ - v1-bundle-{{ checksum "solidus_graphql_api.gemspec" }}
18
+ - v1-bundle-
19
+ - run: bundle check || bundle install
20
+ - save_cache:
21
+ key: v1-bundle-{{ checksum "solidus_graphql_api.gemspec" }}-{{ checksum "Gemfile" }}
22
+ paths:
23
+ - ~/project/vendor/bundle
24
+
25
+ jobs:
26
+ verify-schema-updated:
27
+ docker:
28
+ - image: circleci/ruby:2.5.6-node
29
+ environment:
30
+ BUNDLE_PATH: vendor/bundle
31
+ steps:
32
+ - checkout
33
+ - bundle
34
+ - run:
35
+ name: Check if Schema is up-to-date
36
+ command: |
37
+ mv schema.graphql old_schema.graphql
38
+ bundle exec rake schema:idl
39
+ diff old_schema.graphql schema.graphql
40
+
41
+ run-specs-with-postgres:
42
+ executor: solidusio_extensions/postgres
43
+ steps:
44
+ - solidusio_extensions/run-tests
45
+ - run:
46
+ name: Install & Upload test coverage to Code Climate
47
+ command: |
48
+ curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
49
+ chmod +x ./cc-test-reporter
50
+ ./cc-test-reporter format-coverage -t simplecov -o ./coverage/codeclimate.json
51
+ ./cc-test-reporter upload-coverage
52
+
53
+ run-specs-with-mysql:
54
+ executor: solidusio_extensions/mysql
55
+ steps:
56
+ - solidusio_extensions/run-tests
57
+
58
+ schema-breaking-change-detection:
59
+ docker:
60
+ - image: circleci/ruby:2.5.6-node
61
+ steps:
62
+ - checkout
63
+ - run:
64
+ name: Install GraphQL::SchemaComparator
65
+ command: gem install graphql-schema_comparator
66
+ - run:
67
+ name: Schema Breaking Change detection
68
+ command: rm Gemfile && schema_comparator verify "`git show origin/master:schema.graphql`" schema.graphql
69
+
70
+ workflows:
71
+ "Run specs on supported Solidus versions":
72
+ jobs:
73
+ - verify-schema-updated
74
+ - schema-breaking-change-detection:
75
+ requires:
76
+ - verify-schema-updated
77
+ - run-specs-with-postgres:
78
+ requires:
79
+ - verify-schema-updated
80
+ - run-specs-with-mysql:
81
+ requires:
82
+ - verify-schema-updated
83
+ "Weekly run specs against master":
84
+ triggers:
85
+ - schedule:
86
+ cron: "0 0 * * 4" # every Thursday
87
+ filters:
88
+ branches:
89
+ only:
90
+ - master
91
+ jobs:
92
+ - run-specs-with-postgres
93
+ - run-specs-with-mysql
@@ -0,0 +1,5 @@
1
+ bump:
2
+ recurse: false
3
+ file: 'lib/solidus_graphql_api/version.rb'
4
+ message: Bump SolidusGraphqlApi to %{version}
5
+ tag: true
@@ -0,0 +1,17 @@
1
+ # Number of days of inactivity before an issue becomes stale
2
+ daysUntilStale: 60
3
+ # Number of days of inactivity before a stale issue is closed
4
+ daysUntilClose: 7
5
+ # Issues with these labels will never be considered stale
6
+ exemptLabels:
7
+ - pinned
8
+ - security
9
+ # Label to use when marking an issue as stale
10
+ staleLabel: wontfix
11
+ # Comment to post when marking an issue as stale. Set to `false` to disable
12
+ markComment: >
13
+ This issue has been automatically marked as stale because it has not had
14
+ recent activity. It will be closed if no further activity occurs. Thank you
15
+ for your contributions.
16
+ # Comment to post when closing a stale issue. Set to `false` to disable
17
+ closeComment: false
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ \#*
3
+ *~
4
+ .#*
5
+ .DS_Store
6
+ .idea
7
+ .project
8
+ .sass-cache
9
+ coverage
10
+ Gemfile.lock
11
+ tmp
12
+ nbproject
13
+ pkg
14
+ *.swp
15
+ spec/dummy
16
+ spec/examples.txt
17
+ /sandbox
18
+ .rvmrc
19
+ .ruby-version
20
+ .ruby-gemset
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,62 @@
1
+ require:
2
+ - solidus_dev_support/rubocop
3
+
4
+ Style/ExpandPathArguments:
5
+ Enabled: false
6
+
7
+ Metrics/LineLength:
8
+ Enabled: false
9
+
10
+ Performance/RegexpMatch:
11
+ Enabled: false
12
+
13
+ RSpec/MessageSpies:
14
+ Enabled: false
15
+
16
+ RSpec/NotToNot:
17
+ Enabled: false
18
+
19
+ RSpec/NamedSubject:
20
+ Enabled: false
21
+
22
+ RSpec/VerifiedDoubles:
23
+ Enabled: false
24
+
25
+ RSpec/LeadingSubject:
26
+ Enabled: false
27
+
28
+ RSpec/ContextWording:
29
+ Enabled: false
30
+
31
+ RSpec/NestedGroups:
32
+ Enabled: false
33
+
34
+ RSpec/PredicateMatcher:
35
+ Enabled: false
36
+
37
+ RSpec/DescribeClass:
38
+ Enabled: false
39
+
40
+ RSpec/DescribedClass:
41
+ Enabled: false
42
+
43
+ RSpec/LeakyConstantDeclaration:
44
+ Enabled: false
45
+
46
+ RSpec/AnyInstance:
47
+ Enabled: false
48
+
49
+ RSpec/LetSetup:
50
+ Enabled: false
51
+
52
+ RSpec/HookArgument:
53
+ Enabled: false
54
+
55
+ Layout/AlignArguments:
56
+ Enabled: false
57
+
58
+ Rails/RakeEnvironment:
59
+ Enabled: false
60
+
61
+ Rails/HttpStatus:
62
+ Enabled: false
File without changes
@@ -0,0 +1,57 @@
1
+ # How to contribute
2
+
3
+ Third-party patches are essential to any great open source project. We want
4
+ to keep it as easy as possible to contribute changes that get things working
5
+ in your environment. There are a few guidelines that we need contributors to
6
+ follow so that we can have a chance of keeping on top of things.
7
+
8
+ ## Getting Started
9
+
10
+ * Make sure you have a [GitHub account](https://github.com/signup/free)
11
+ * Submit a ticket for your issue, assuming one does not already exist.
12
+ * Clearly describe the issue including steps to reproduce when it is a bug.
13
+ * Make sure you fill in the earliest version that you know has the issue.
14
+ * Fork the repository on GitHub
15
+
16
+ ## Making Changes
17
+
18
+ * Create a topic branch from where you want to base your work.
19
+ * This is usually the master branch.
20
+ * Only target release branches if you are certain your fix must be on that
21
+ branch.
22
+ * To quickly create a topic branch based on master; `git branch
23
+ fix/master/my_contribution master` then checkout the new branch with `git
24
+ checkout fix/master/my_contribution`. Please avoid working directly on the
25
+ `master` branch.
26
+ * Make commits of logical units.
27
+ * Check for unnecessary whitespace with `git diff --check` before committing.
28
+ * Make sure your commit messages are in the proper format.
29
+
30
+ ````
31
+ (#99999) Make the example in CONTRIBUTING imperative and concrete
32
+
33
+ Without this patch applied the example commit message in the CONTRIBUTING
34
+ document is not a concrete example. This is a problem because the
35
+ contributor is left to imagine what the commit message should look like
36
+ based on a description rather than an example. This patch fixes the
37
+ problem by making the example concrete and imperative.
38
+
39
+ The first line is a real life imperative statement with a ticket number
40
+ from our issue tracker. The body describes the behavior without the patch,
41
+ why this is a problem, and how the patch fixes the problem when applied.
42
+ ````
43
+
44
+ * Make sure you have added the necessary tests for your changes.
45
+ * Run _all_ the tests to assure nothing else was accidentally broken.
46
+
47
+ ## Submitting Changes
48
+
49
+ * Push your changes to a topic branch in your fork of the repository.
50
+ * Submit a pull request to the extensions repository.
51
+ * Update any Github issues to mark that you have submitted code and are ready for it to be reviewed.
52
+ * Include a link to the pull request in the ticket
53
+
54
+ # Additional Resources
55
+
56
+ * [General GitHub documentation](http://help.github.com/)
57
+ * [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
data/Gemfile ADDED
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
+
6
+ branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
7
+ gem 'solidus', github: 'solidusio/solidus', branch: branch
8
+
9
+ # Needed to help Bundler figure out how to resolve dependencies,
10
+ # otherwise it takes forever to resolve them.
11
+ # See https://github.com/bundler/bundler/issues/6677
12
+ gem 'rails', '>0.a'
13
+
14
+ # Provides basic authentication functionality for testing parts of your engine
15
+ gem 'solidus_auth_devise'
16
+
17
+ case ENV['DB']
18
+ when 'mysql'
19
+ gem 'mysql2'
20
+ when 'postgresql'
21
+ gem 'pg'
22
+ else
23
+ gem 'sqlite3'
24
+ end
25
+
26
+ gemspec
27
+
28
+ # Use a local Gemfile to include development dependencies that might not be
29
+ # relevant for the project or for other contributors, e.g. pry-byebug.
30
+ #
31
+ # We use `send` instead of calling `eval_gemfile` to work around an issue with
32
+ # how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
33
+ send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2020 Nebulab
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Solidus nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2019 [name of plugin creator]
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Solidus nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,245 @@
1
+ [![Maintainability](https://api.codeclimate.com/v1/badges/8ea7739ad6726ad8cfa7/maintainability)](https://codeclimate.com/github/solidusio-contrib/solidus_graphql_api/maintainability)
2
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/8ea7739ad6726ad8cfa7/test_coverage)](https://codeclimate.com/github/solidusio-contrib/solidus_graphql_api/test_coverage)
3
+ [![CircleCI](https://circleci.com/gh/solidusio-contrib/solidus_graphql_api.svg?style=svg)](https://circleci.com/gh/solidusio-contrib/solidus_graphql_api)
4
+
5
+ # SolidusGraphqlApi
6
+
7
+ Provides a [graphql](https://graphql.org/) api for the [Solidus](https://github.com/solidusio/solidus) ecommerce framework.
8
+
9
+ ## Installation
10
+
11
+ Add solidus_graphql_api to your Gemfile:
12
+
13
+ ```ruby
14
+ gem 'solidus_graphql_api'
15
+ ```
16
+
17
+ Bundle your dependencies:
18
+
19
+ ```shell
20
+ bundle
21
+ ```
22
+
23
+ Unlike the REST API which has a variety of endpoints, the GraphQL API has a
24
+ single endpoint accessible under `/graphql`.
25
+
26
+ For example in development you can use:
27
+
28
+ ```
29
+ POST http://localhost:3000/graphql
30
+ ```
31
+
32
+ ## Customizations
33
+
34
+ You can extend the gem functionality through decorators, just like Solidus.
35
+
36
+ For example, assuming we are placing our grapqhl decorators in `app/graphql/types`:
37
+
38
+ ### Adding a new field
39
+
40
+ ```ruby
41
+ module Graphql
42
+ module Types
43
+ module ProductDecorator
44
+ def self.prepended(base)
45
+ base.field :test, GraphQL::Types::String, null: true
46
+ end
47
+
48
+ def test
49
+ 'test'
50
+ end
51
+
52
+ SolidusGraphqlApi::Types::Product.prepend self
53
+ end
54
+ end
55
+ end
56
+ ```
57
+
58
+ or also, if we want to add the taxon relation to the type product:
59
+
60
+ ```ruby
61
+ module Graphql
62
+ module Types
63
+ module ProductDecorator
64
+ def self.prepended(base)
65
+ base.field :taxons, SolidusGraphqlApi::Types::Taxon.connection_type, null: true
66
+ end
67
+
68
+ def taxons
69
+ SolidusGraphqlApi::BatchLoader.for(object, :taxons)
70
+ end
71
+
72
+ SolidusGraphqlApi::Types::Product.prepend self
73
+ end
74
+ end
75
+ end
76
+ ```
77
+
78
+ ### Modifying an existing field
79
+
80
+ Like for adding a new field, we modify the `name` field in the same way:
81
+
82
+ ```ruby
83
+ module Graphql
84
+ module Types
85
+ module ProductDecorator
86
+ def self.prepended(base)
87
+ base.field :name, GraphQL::Types::String, null: true
88
+ end
89
+
90
+ def name
91
+ object.concat(' ', 'Graphql')
92
+ end
93
+
94
+ SolidusGraphqlApi::Types::Product.prepend self
95
+ end
96
+ end
97
+ end
98
+ ```
99
+
100
+ ### Removing a field
101
+
102
+ ```ruby
103
+ module Graphql
104
+ module Types
105
+ module ProductDecorator
106
+ def self.prepended(base)
107
+ base.remove_field :name
108
+ end
109
+
110
+ SolidusGraphqlApi::Types::Product.prepend self
111
+ end
112
+ end
113
+ end
114
+ ```
115
+
116
+ ### Adding a new Type
117
+
118
+ Let's say we want the Product type to return its stock_items:
119
+
120
+ First we create a StockItem type:
121
+
122
+ ```ruby
123
+ module Graphql
124
+ module Types
125
+ class StockItem < SolidusGraphqlApi::Types::Base::RelayNode
126
+ description 'StockItem.'
127
+
128
+ field :count_on_hand, Integer, null: false
129
+ end
130
+ end
131
+ end
132
+ ```
133
+
134
+ And in the product decorator type:
135
+
136
+ ```ruby
137
+ require_relative 'stock_item'
138
+
139
+ module Graphql
140
+ module Types
141
+ module ProductDecorator
142
+ def self.prepended(base)
143
+ base.field :stock_items, Graphql::Types::StockItem.connection_type, null: false
144
+ end
145
+
146
+ def stock_items
147
+ object.stock_items
148
+ end
149
+
150
+ SolidusGraphqlApi::Types::Product.prepend self
151
+ end
152
+ end
153
+ end
154
+ ```
155
+
156
+ The query may look something like:
157
+
158
+ ```ruby
159
+ query productBySlug ($slug: String!) {
160
+ productBySlug (slug: $slug) {
161
+ stockItems {
162
+ nodes {
163
+ countOnHand
164
+ }
165
+ }
166
+ }
167
+ }
168
+ ```
169
+
170
+ ### Adding a new Query
171
+
172
+ ```ruby
173
+ module Graphql
174
+ module Types
175
+ module QueryDecorator
176
+ def self.prepended(base)
177
+ base.field :taxons, SolidusGraphqlApi::Types::Taxon.connection_type, null: false
178
+ end
179
+
180
+ def taxons
181
+ Spree::Taxon.all
182
+ end
183
+
184
+ SolidusGraphqlApi::Types::Query.prepend self
185
+ end
186
+ end
187
+ end
188
+ ```
189
+
190
+ In your application you probably want to create a query object to retrieves the taxons.
191
+ Check `SolidusGraphqlApi::Types::Query` for examples.
192
+
193
+ ## Development
194
+
195
+ ### Testing the extension
196
+
197
+ First bundle your dependencies, then run `bin/rake`. `bin/rake` will default to building the dummy
198
+ app if it does not exist, then it will run specs. The dummy app can be regenerated by using
199
+ `bin/rake extension:test_app`.
200
+
201
+ ```shell
202
+ bundle
203
+ bin/rake
204
+ ```
205
+
206
+ To run [Rubocop](https://github.com/bbatsov/rubocop) static code analysis run
207
+
208
+ ```shell
209
+ bundle exec rubocop
210
+ ```
211
+
212
+ When testing your application's integration with this extension you may use its factories.
213
+ Simply add this require statement to your spec_helper:
214
+
215
+ ```ruby
216
+ require 'solidus_graphql_api/factories'
217
+ ```
218
+
219
+ ## Running the sandbox
220
+
221
+ To run this extension in a sandboxed Solidus application, you can run `bin/sandbox`. The path for
222
+ the sandbox app is `./sandbox` and `bin/rails` will forward any Rails commands to
223
+ `sandbox/bin/rails`.
224
+
225
+ Here's an example:
226
+
227
+ ```shell
228
+ $ bin/rails server
229
+ => Booting Puma
230
+ => Rails 6.0.2.1 application starting in development
231
+ * Listening on tcp://127.0.0.1:3000
232
+ Use Ctrl-C to stop
233
+ ```
234
+
235
+ ### Releasing new versions
236
+
237
+ Your new extension version can be released using `gem-release` like this:
238
+
239
+ ```shell
240
+ bundle exec gem bump -v VERSION --tag --push --remote upstream && gem release
241
+ ```
242
+
243
+ ## License
244
+
245
+ Copyright (c) 2020 Nebulab, released under the New BSD License.