File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed
Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change 6262def make_api_request
6363 # 1. Create API client without session information
6464 # The graphql_client will use `ShopifyAPI::Context.active_session` when making API calls
65- graphql_client = ShopifyAPI ::Clients ::Graphql ::Admin .new
65+ # you can set the api version for your GraphQL client
66+ graphql_client = ShopifyAPI ::Clients ::Graphql ::Admin .new (api_version: " 2024-07" )
67+
68+ # REST example
69+ ShopifyAPI ::Context .load_rest_resources(api_version: " 2024-07" )
6670
6771 # 2. Use API client to make queries
72+ # Graphql
73+ query = <<~QUERY
74+ {
75+ products(first: 10) {
76+ edges {
77+ cursor
78+ node {
79+ id
80+ title
81+ onlineStoreUrl
82+ }
83+ }
84+ }
85+ }
86+ QUERY
87+
88+ response = graphql_client.query(query: query)
89+
90+ # REST
91+ product_count = ShopifyAPI ::Product .count
92+
6893 ...
6994end
7095
You can’t perform that action at this time.
0 commit comments