Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Graphql Admin client should not require a session argument

未关闭
#1,352 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
ruby
领域
api

调研方向

从 lib/shopify_api/clients/graphql/admin.rb 开始,将其 initializer 与 REST Admin Client 的行为进行比较。检查 docs/usage/custom_apps.md 中记录的构造方式,然后让实现和文档在 session 参数是否可选这一点上保持一致;完成标准是文档中的初始化不再引发参数错误。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Ruby
星标
1.1k
派生
484
平均合并
4 小时 38 分钟
30 天内合并 PR
1

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Shopify/shopify-api-ruby 的其他 Issue

查看 Shopify/shopify-api-ruby 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。