Skip to content

Commit e3c4104

Browse files
authored
Adds api version configuration example for custom app
- Adds graphql client example with api version - Adds REST api version setting example
1 parent c029d8a commit e3c4104

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

docs/usage/custom_apps.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,34 @@ end
6262
def 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
...
6994
end
7095

0 commit comments

Comments
 (0)