File tree Expand file tree Collapse file tree 1 file changed +32
-1
lines changed
Expand file tree Collapse file tree 1 file changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,15 @@ def configure_app
5353 access_token: " the_token_for_your_custom_app_found_in_admin"
5454 )
5555
56+ ShopifyAPI ::Context .setup(
57+ api_key: " <api-key>" ,
58+ api_secret_key: " <api-secret-key>" ,
59+ scope: " read_orders,read_products,etc" ,
60+ is_embedded: true , # Set to true if you are building an embedded app
61+ api_version: " 2024-01" , # The version of the API you would like to use
62+ is_private: true , # Set to true if you have an existing private app
63+ )
64+
5665 # Activate session to be used in all API calls
5766 # session must be type `ShopifyAPI::Auth::Session`
5867 ShopifyAPI ::Context .activate_session(session)
6271def make_api_request
6372 # 1. Create API client without session information
6473 # The graphql_client will use `ShopifyAPI::Context.active_session` when making API calls
65- graphql_client = ShopifyAPI ::Clients ::Graphql ::Admin .new
74+ # you can set the api version for your GraphQL client to override the api version in ShopifyAPI::Context
75+ graphql_client = ShopifyAPI ::Clients ::Graphql ::Admin .new (api_version: " 2024-07" )
6676
6777 # 2. Use API client to make queries
78+ # Graphql
79+ query = <<~QUERY
80+ {
81+ products(first: 10) {
82+ edges {
83+ cursor
84+ node {
85+ id
86+ title
87+ onlineStoreUrl
88+ }
89+ }
90+ }
91+ }
92+ QUERY
93+
94+ response = graphql_client.query(query: query)
95+
96+ # Use REST resources to make authenticated API call
97+ product_count = ShopifyAPI ::Product .count
98+
6899 ...
69100end
70101
You can’t perform that action at this time.
0 commit comments