Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphql Admin client should not require a session argument #1352

Open
reed opened this issue Dec 19, 2024 · 0 comments
Open

Graphql Admin client should not require a session argument #1352

reed opened this issue Dec 19, 2024 · 0 comments

Comments

@reed
Copy link

reed commented Dec 19, 2024

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):

Image

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant