cost 309 ms
查询字符串参数应该是 String -Rails Action Cable & graphql through apollo - Query string argument should be a String -Rails Action Cable & graphql through apollo

我将 rails 6.1 graphql gem 与 Apollo 一起使用来执行订阅。 它适用于正常查询和突变,但 Rails 抱怨订阅。 在我的前端:const cable = ActionCable.createConsumer( `${process.env.GATSBY_CABLE_ ...

使用 Rspec 在 Rails 上测试 graphQL 突变,resolve 返回错误数量的参数 - testing graphQL mutations on rails using Rspec, resolve returns wrong number of arguments

我正在尝试测试 graphQL 突变,但我无法解决错误。 我想为每个作者创作一本书 在 book.rb 中创建_book def 考试: 我运行测试时遇到的错误: 失败/错误:def self.create_book(genre_id,author_id)create(genre_ ...

如何使用 graphql-ruby 引发两个错误? - How do I raise two errors with graphql-ruby?

我正在使用 graphql-ruby gem 并且我有一个更新记录的突变。 这一切正常,但现在我想包含phony_rails gem 来验证电话号码。 问题作为一个拥有更多 FE 经验的开发人员,我对 rails 或 ruby 不是很好,我正在使用它来学习。 也就是说,我有两个电话号码要验证—— ...

GraphQL-Ruby:执行突变时,出现错误 Variable $...... is declared by ....(mutation).... but not used - GraphQL-Ruby : When executing a mutation, get error Variable $...... is declared by ....(mutation).... but not used

我正在 GraphQL ruby 上磨牙,这看起来应该是基本的,但文档使这很难理解。 我这里go哪里错了? 我的目标只是在我的 Ruby 应用程序中进行 GraphQL 突变。 应用程序/graphql/types/mutation_type.rb 这是app/graphql/mutations/ ...

GrapqhQL ruby / 默认添加 __typename 作为响应 - GrapqhQL ruby / adding __typename by default in response

玩弄 graphql 并查看一些库(主要是 apollo 和 urlql),我发现它们都严重依赖后端在有效负载中返回的 __typename 信息。 Urlql 会在初始请求中的每个节点上添加它(一旦启用某些功能)。 您不必在请求客户端中键入它。 因此,基本上他们正在转换您的 graphql 输入 ...

ActiveStorage - 无法找到或构建 blob:预期可附加,得到 # <actiondispatch::http::uploadedfile< div><div id="text_translate"><h3> 重现步骤</h3><p><strong>宝石</strong></p><pre class="lang-rb prettyprint-override">gem 'graphql', '1.13.2' gem 'apollo_upload_server', '2.1.0'</pre><p> app/graphql/mutations/create_document.rb</p><pre class="lang-rb prettyprint-override"> module Mutations class CreateDocument &lt; Mutations::BaseMutation description "Create a document" argument:doc, ApolloUploadServer::Upload, required: true, description: "The document to upload" field:document, Types::Objects::DocumentType, null: false field:code, Types::Enums::CodeEnum, null: false def resolve(doc:) authenticate_user document = context[:current_user].documents.build(doc: doc) if document.save {document: document, code: "SUCCESS"} else raise GraphQL::ExecutionError.new(document.errors.full_messages.join(", "), extensions: {code: "UNPROCESSABLE_ENTITY", errors: document.errors}) end end end end</pre><p> Query GraphQL Server</p><pre class="lang-sh prettyprint-override"> Processing by GraphqlController#execute as */* 17:34:47 web.1 | 17:34:47 web.1 | Variables: 17:34:47 web.1 | {"doc"=&gt; 17:34:47 web.1 | #&lt;ActionDispatch::Http::UploadedFile:0x0000ffff6c90ffd0 17:34:47 web.1 | @content_type="image/jpeg", 17:34:47 web.1 | @headers= 17:34:47 web.1 | "Content-Disposition: form-data; name=\"0\"; filename=\"www.abcd.jpg\"\r\n" + 17:34:47 web.1 | "Content-Type: image/jpeg\r\n", 17:34:47 web.1 | @original_filename="www.YTS.MX.jpg", 17:34:47 web.1 | @tempfile=#&lt;File:/tmp/RackMultipart20220101-9-dn78ar.jpg&gt;&gt;} 17:34:47 web.1 | 17:34:47 web.1 | Query: 17:34:47 web.1 | mutation createDocument($doc: Upload:){createDocument(input: {doc: $doc}){document{url}}}</pre><p> app/models/document.rb</p><pre class="lang-rb prettyprint-override"> class Document &lt; ApplicationRecord ## RELATIONSHIPS has_one_attached:doc belongs_to:documentable, polymorphic: true, optional: true belongs_to:user, optional: true ## VALIDATIONS validate:doc_presence, on: :create def doc_presence pattern = %r{^(image|application|text)/(.)+$} unless doc.attached? &amp;&amp; pattern.match?(doc.attachment.blob.content_type) errors.add(:doc, I18n.t("errors.models.document.file_presence")) end end end</pre><p> <strong>Postman</strong> URL:POST http://localhost:3000/graphql <em>form-data</em></p><pre> "operations" = {"query":"mutation createDocument($doc: Upload:){createDocument(input: {doc, $doc}){document{url}}}": "variables": { "doc": null }} "map" = { "0". ["variables.doc"]} "0" = FILE_TO_BE_UPLOADED</pre><p> spec/graphql/mutations/create_document_spec.rb</p><pre class="lang-rb prettyprint-override"> require 'rails_helper' module Mutations RSpec.describe CreateDocument, type: :request do describe '.resolve' do let(:session) {FactoryBot.create(:session)} it 'create a document for the user' do session.user.confirm headers = sign_in_test_headers session params = FactoryBot.attributes_for(:document, :with_image, user_id: session.user_id) query = &lt;&lt;-GRAPHQL mutation ($input: CreateDocumentInput:) { createDocument(input. $input) { document { id url } } } GRAPHQL file = fixture_file_upload("spec/support/fixtures/image:png") variables = {input: {doc: ::ApolloUploadServer::Wrappers:.UploadedFile.new(fixture_file_upload("spec/support/fixtures/image.png"))}} response = ApiSchema,execute(query: variables, variables: context: {current_user. session.user}) end end end end</pre><h3> 预期行为</h3><p>文件应该附上</p><h3>实际行为</h3><pre class="lang-sh prettyprint-override">Could not find or build blob: expected attachable, got #&lt;ActionDispatch::Http::UploadedFile:0x0000ffff6c90ffd0 @tempfile=#&lt;Tempfile:/tmp/RackMultipart20220101-9-dn78ar.jpg&gt;, @original_filename="www.abcd.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"0\"; filename=\"www.abcd.jpg\"\r\nContent-Type: image/jpeg\r\n"&gt;</pre><pre class="lang-sh prettyprint-override"> ArgumentError: Could not find or build blob: expected attachable, got #&lt;Rack::Test::UploadedFile:0x0000aaaafe8ba7a0 @original_filename="image.png", @tempfile=#&lt;Tempfile:/tmp/image20220101-1-c5c4q4.png&gt;, @content_type=nil&gt; # /usr/local/bundle/gems/activestorage-7.0.0/lib/active_storage/attached/changes/create_one.rb:74:in `find_or_build_blob' # /usr/local/bundle/gems/activestorage-7.0.0/lib/active_storage/attached/changes/create_one.rb:20:in `blob' # /usr/local/bundle/gems/activestorage-7.0.0/lib/active_storage/attached/changes/create_one.rb:12:in `initialize' # /usr/local/bundle/gems/activestorage-7.0.0/lib/active_storage/attached/model.rb:65:in `new' # /usr/local/bundle/gems/activestorage-7.0.0/lib/active_storage/attached/model.rb:65:in `doc=' # /usr/local/bundle/gems/enumerize-2.5.0/lib/enumerize/base.rb:53:in `initialize' #./app/graphql/mutations/create_document.rb:13:in `resolve' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/schema/resolver.rb:107:in `public_send' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/schema/resolver.rb:107:in `block (3 levels) in resolve_with_support' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/schema.rb:118:in `after_lazy' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/schema/resolver.rb:95:in `block (2 levels) in resolve_with_support' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/schema.rb:118:in `after_lazy' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/schema/resolver.rb:86:in `block in resolve_with_support' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/schema.rb:118:in `after_lazy' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/schema/resolver.rb:75:in `resolve_with_support' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/schema/relay_classic_mutation.rb:64:in `resolve_with_support' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/schema/field.rb:812:in `public_send' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/schema/field.rb:812:in `block in public_send_field' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/schema/field.rb:848:in `with_extensions' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/schema/field.rb:794:in `public_send_field' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/schema/field.rb:708:in `block in resolve' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/schema.rb:118:in `after_lazy' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/schema/field.rb:706:in `resolve' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/execution/interpreter/runtime.rb:510:in `block (4 levels) in evaluate_selection_with_args' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/tracing.rb:66:in `trace' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/execution/interpreter/runtime.rb:509:in `block (3 levels) in evaluate_selection_with_args' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/query.rb:366:in `block in with_error_handling' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/execution/errors.rb:107:in `with_error_handling' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/query.rb:365:in `with_error_handling' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/execution/interpreter/runtime.rb:508:in `block (2 levels) in evaluate_selection_with_args' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/execution/interpreter/runtime.rb:796:in `resolve_with_directives' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/execution/interpreter/runtime.rb:505:in `block in evaluate_selection_with_args' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/execution/interpreter/runtime.rb:899:in `after_lazy' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/execution/interpreter/runtime.rb:439:in `evaluate_selection_with_args' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/execution/interpreter/runtime.rb:431:in `block in evaluate_selection' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/schema/member/has_arguments.rb:204:in `block (3 levels) in coerce_arguments' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/dataloader.rb:181:in `block in run' # /usr/local/bundle/gems/graphql-1.13.2/lib/graphql/dataloader.rb:303:in `block in spawn_fiber'</pre><h3> 系统配置</h3><p><strong>导轨版本</strong>:7.0.0</p><p> <strong>Ruby 版本</strong>:3.0.3 </p></div></actiondispatch::http::uploadedfile<> - ActiveStorage - Could not find or build blob: expected attachable, got #<ActionDispatch::Http::UploadedFile

重现步骤宝石gem 'graphql', '1.13.2' gem 'apollo_upload_server', '2.1.0' app/graphql/mutations/create_document.rbmodule Mutations class CreateDocument &l ...

向 graphql-ruby 实现添加多个过滤器 - Adding multiple filters to graphql-ruby implementation

我想为我的 GraphQL 类型添加过滤和排序(使用graphql-ruby gem)。 我一直在寻找现有的解决方案,我发现唯一合理的选择是创建一个自定义解析器。 这种方法的问题是我“失去”了 Active Record 功能,例如在模型上使用自定义方法进行过滤或字段解析。 有没有人遇到过一个体面的 ...

Graphql Ruby N + 1 查询因为方法调用另一个关系 - Graphql Ruby N + 1 Queries because of method calling another relationship

我正在使用 graphql 和批处理加载程序 gem 并运行到这个 N+1 查询: 我有一个属于一个帐户的日历约会,当我们显示约会时间时,我们基于帐户的时区。 导致 N+1 查询 我还有许多其他类似的实例方法创建 N+1 查询的示例,并且不确定解决此问题的最佳方法。 到目前为止,我刚刚看到了直接征服 ...

如何允许 graphql-ruby 提供驼峰式应用程序数据? - How do I allow graphql-ruby to serve app data that is camel-case?

我是 graphql-ruby 的新手,在查询从现有应用程序提供的驼峰式数据时遇到问题。 我试图在 graphql-ruby 跟踪器中搜索一些答案,但其中大多数都引用了突变,我在另一个方向应用时遇到了麻烦。 应用程序中的大部分数据都以蛇形盒形式提供,并且运行良好。 但是,由于在我接手这个项目之前很 ...

GraphQL 查询中的分组 - Grouping in GraphQL query

我是 GraphQl 的新手并正在学习它。 目前我有单个数据库表 - student_courses ,如下所示: 我已将 model 映射到单个 GraphQL object。 所以我得到 GraphQL API 响应作为表中每一行的单独 json 对象。 我想了解如何按student_id, s ...


 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM