File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed
lib/graphql/schema/member Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
+ require 'irb/ruby-token'
3
+
2
4
module GraphQL
3
5
class Schema
4
6
class Member
@@ -38,16 +40,23 @@ def get_field(field_name)
38
40
end
39
41
end
40
42
43
+ # A list of Ruby keywords.
44
+ #
45
+ # @api private
46
+ RUBY_KEYWORDS = RubyToken ::TokenDefinitions . select { |definition | definition [ 1 ] == RubyToken ::TkId }
47
+ . map { |definition | definition [ 2 ] }
48
+ . compact
49
+
50
+ # A list of GraphQL-Ruby keywords.
51
+ #
52
+ # @api private
53
+ GRAPHQL_RUBY_KEYWORDS = [ :context , :object , :method ]
54
+
41
55
# A list of field names that we should advise users to pick a different
42
56
# resolve method name.
43
57
#
44
58
# @api private
45
- CONFLICT_FIELD_NAMES = Set . new ( [
46
- # GraphQL-Ruby conflicts
47
- :context , :object ,
48
- # Ruby built-ins conflicts
49
- :method , :class
50
- ] )
59
+ CONFLICT_FIELD_NAMES = Set . new ( GRAPHQL_RUBY_KEYWORDS + RUBY_KEYWORDS )
51
60
52
61
# Register this field with the class, overriding a previous one if needed.
53
62
# @param field_defn [GraphQL::Schema::Field]
You can’t perform that action at this time.
0 commit comments