Shopify / Shopify/shopify-api-ruby
Graphql Admin client should not require a session argument
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 1.1k
- Forks
- 484
- PR merge metrics
- No merged PRs in 30d
Description
The documentation at custom_apps.md indicates that you do not need to pass in a session argument when initializing a ShopifyAPI::Clients::Graphql::Admin client because it will use the active session (if it exists):
However, this example would raise an exception because the session argument is required:
# lib/shopify_api/clients/graphql/admin.rb
module ShopifyAPI
module Clients
module Graphql
class Admin < Client
sig { params(session: T.nilable(Auth::Session), api_version: T.nilable(String)).void }
def initialize(session:, api_version: nil) # session argument does not have a default value
super(session: session, base_path: "/admin/api", api_version: api_version)
end
end
end
end
end
Therefore if you want to use the active session, you have to pass in session: nil:
graphql_client = ShopifyAPI::Clients::Graphql::Admin.new(session: nil, api_version: "2024-07")
This seems counter-intuitive to me, as it makes it look like the code is deliberately saying it doesn't want to use a session. I think that what is shown in the documentation is how it should work, that you can omit the argument in order to use the active session. The REST Admin Client behaves this way, so I think it only makes sense that the Graphql Admin Client does too.
I can submit a PR to make this change if you'd like. Or if you disagree and want to keep the existing behavior, then I can submit a PR to fix the documentation.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with lib/shopify_api/clients/graphql/admin.rb and compare its initializer with the REST Admin Client behavior. Check docs/usage/custom_apps.md for the documented construction, then make the implementation and documentation agree on whether the session argument is optional; done means the documented initialization no longer raises an argument error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100