Skip to content

Commit

Permalink
Adds api version configuration example for custom app
Browse files Browse the repository at this point in the history
- Adds graphql client example with api version
- Adds REST api version setting example
  • Loading branch information
sle-c committed Jul 16, 2024
1 parent c029d8a commit e3c4104
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion docs/usage/custom_apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,34 @@ end
def make_api_request
# 1. Create API client without session information
# The graphql_client will use `ShopifyAPI::Context.active_session` when making API calls
graphql_client = ShopifyAPI::Clients::Graphql::Admin.new
# you can set the api version for your GraphQL client
graphql_client = ShopifyAPI::Clients::Graphql::Admin.new(api_version: "2024-07")

# REST example
ShopifyAPI::Context.load_rest_resources(api_version: "2024-07")

# 2. Use API client to make queries
# Graphql
query = <<~QUERY
{
products(first: 10) {
edges {
cursor
node {
id
title
onlineStoreUrl
}
}
}
}
QUERY

response = graphql_client.query(query: query)

# REST
product_count = ShopifyAPI::Product.count

...
end

Expand Down

0 comments on commit e3c4104

Please sign in to comment.