Skip to content

Commit 0e5ea6e

Browse files
authored
Merge pull request #2 from svtek/newRelay
upgradeToNewRelay
2 parents 32d022d + 5ece9e2 commit 0e5ea6e

File tree

7 files changed

+11
-14
lines changed

7 files changed

+11
-14
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
.gem
1+
*.gem
22
.idea/

Gemfile.lock

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,3 @@ PLATFORMS
100100

101101
DEPENDENCIES
102102
rails
103-
104-
BUNDLED WITH
105-
1.11.2

lib/generators/graphql/graphql_helpers.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def create_type(model)
2727
description '#{model.to_s} type'
2828
2929
interfaces [NodeIdentification.interface]
30-
31-
field :id, field: GraphQL::Relay::GlobalIdField.new('#{model.to_s}')
30+
31+
global_id_field :id
3232
# End of fields
3333
end
3434
FILE
@@ -41,7 +41,7 @@ def add_fields(model)
4141
next if columns[k].name == 'id'
4242

4343
if columns[k].type.present?
44-
inject_into_file type_path(model), after: "field :id, field: GraphQL::Relay::GlobalIdField.new('#{model.to_s}')\n" do <<-FILE
44+
inject_into_file type_path(model), after: "global_id_field :id\n" do <<-FILE
4545
field :#{columns[k].name}, types.#{type_mapper[columns[k].type]}
4646
FILE
4747
end

lib/generators/graphql/init_generator.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ class InitGenerator < Rails::Generators::Base
44
source_root File.expand_path('../templates', __FILE__)
55

66
def add_gems
7-
gem 'graphql'
8-
gem 'graphql-relay'
7+
gem 'graphql'
98
gem 'graphiql-rails'
109
gem 'graphql-formatter'
1110
end
@@ -36,4 +35,3 @@ def copy_templates
3635
end
3736
end
3837
end
39-

lib/generators/graphql/templates/graph/node_identification.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
type_from_object -> (object) do
1313
(object.class.name + 'Type').constantize
1414
end
15-
end
15+
end

lib/generators/graphql/templates/graph/relay_schema.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
RelaySchema = GraphQL::Schema.new(query: QueryType, mutation: MutationType)
22

3+
RelaySchema.node_identification = NodeIdentification
4+
35
module RelaySchemaHelpers
46
SCHEMA_DIR = Rails.root.join('app/assets/javascripts/relay/')
57
SCHEMA_PATH = File.join(SCHEMA_DIR, 'schema.json')
@@ -30,4 +32,4 @@ def remove
3032

3133
end
3234

33-
RelaySchema.extend RelaySchemaHelpers
35+
RelaySchema.extend RelaySchemaHelpers

lib/generators/graphql/templates/graph/types/root_level_type.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44

55
interfaces [NodeIdentification.interface]
66

7-
field :id, field: GraphQL::Relay::GlobalIdField.new('RootLevel')
8-
end
7+
global_id_field :id
8+
end

0 commit comments

Comments
 (0)