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
53
53
access_token: " the_token_for_your_custom_app_found_in_admin"
54
54
)
55
55
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
+
56
65
# Activate session to be used in all API calls
57
66
# session must be type `ShopifyAPI::Auth::Session`
58
67
ShopifyAPI ::Context .activate_session(session)
62
71
def make_api_request
63
72
# 1. Create API client without session information
64
73
# 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" )
66
76
67
77
# 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
+
68
99
...
69
100
end
70
101
You can’t perform that action at this time.
0 commit comments