gpt4 book ai didi

ruby-on-rails - 在生产环境中禁用 GraphQL 自省(introspection)请求

转载 作者:数据小太阳 更新时间:2023-10-29 08:42:39 26 4
gpt4 key购买 nike

出于公司政策原因,我必须禁用 graphql-ruby gem 的自省(introspection)功能(使 __schema 请求失败/返回 404)。

我如何实现这一目标?

该应用程序基于 Ruby on Rails 版本 5.2.2,graphql-ruby gem 版本为 1.8.12。

最佳答案

来自graphql-ruby documentation :

You can re-implement these fields or create new ones by creating a custom EntryPoints class in your introspection namespace:

module Introspection
class EntryPoints < GraphQL::Introspection::EntryPoints
# ...
end
end

也就是说,只需引入 def __schema 方法重定向到 404 或显式响应 404


FWIW,here is the original code你要覆盖。

关于ruby-on-rails - 在生产环境中禁用 GraphQL 自省(introspection)请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54062534/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com