Skip to content

Rails 6: Graphql class based approach#1623

Closed
Tooyosi wants to merge 4 commits intomasterfrom
rails-6-upgrade-graphql
Closed

Rails 6: Graphql class based approach#1623
Tooyosi wants to merge 4 commits intomasterfrom
rails-6-upgrade-graphql

Conversation

@Tooyosi
Copy link
Copy Markdown
Collaborator

@Tooyosi Tooyosi commented Apr 13, 2025

Failure/Error:
  CaesarSchema = GraphQL::Schema.define do
    query(QueryRoot)
    mutation(MutationRoot)
  end

NoMethodError:
  undefined method `define' for GraphQL::Schema:Class
  Did you mean?  defined?
# ./app/graphql/caesar_schema.rb:1:in `<main>'
# ./spec/graphql/caesar_schema_spec.rb:3:in `<main>'

Error is caused due to changes from use of objects to classes from graphql 1.xx to 2.xx
See:
https://imaharu.github.io/graphql-ruby-doc-ja/schema/class_based_api.html
https://graphql-ruby.org/mutations/mutation_classes

@Tooyosi Tooyosi requested review from yuenmichelle1 and zwolf April 13, 2025 19:49
Comment thread Gemfile
if next?
gem "rails", '~> 6.0'
else
gem 'rails', '~> 5.2'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bundler/DuplicatedGem: Gem rails requirements already given on line 15 of the Gemfile.

Comment thread Gemfile
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2'
if next?
gem "rails", '~> 6.0'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

Comment thread Gemfile
@@ -1,3 +1,6 @@
def next?
File.basename(__FILE__) == "Gemfile.next"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

Comment thread Gemfile
@@ -1,3 +1,6 @@
def next?
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.

class CaesarSchema < GraphQL::Schema
query(Types::QueryRoot)
mutation(Types::MutationRoot)
end No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/TrailingBlankLines: Final newline missing.

@@ -0,0 +1,9 @@
# app/graphql/types/credential_type.rb
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.

field 'url', String, null: true
field 'status', Enums::DataRequestStatus, null: false
end
end
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/EndAlignment: end at 12, 2 is not aligned with module at 2, 0.

@@ -0,0 +1,12 @@
# app/graphql/types/data_request.rb
module Types
class DataRequest < GraphQL::Schema::Object
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/IndentationWidth: Use 2 (not 4) spaces for indentation.
Style/Documentation: Missing top-level class documentation comment.

@@ -0,0 +1,12 @@
# app/graphql/types/data_request.rb
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.

# app/graphql/types/enums/data_request_requested_data.rb
module Types
module Enums
class DataRequestRequestedData < GraphQL::Schema::Enum
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/Documentation: Missing top-level class documentation comment.

@lcjohnso
Copy link
Copy Markdown
Member

Close; resolved in #1665

@lcjohnso lcjohnso closed this Apr 15, 2026
@lcjohnso lcjohnso deleted the rails-6-upgrade-graphql branch April 15, 2026 04:34
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

Successfully merging this pull request may close these issues.

2 participants