Commit b30e088
committed
Prefer
`GraphQL::Query#operation_name` is initially only set to what's passed
into `GraphQL::Query.new`. For a query which has only one operation,
it gets populated later when the query AST is parsed:
https://github.com/rmosolgo/graphql-ruby/blob/v2.5.18/lib/graphql/query.rb#L489-L491
`GraphQL::Query#selected_operation_name` is safer to use--it parses the
AST when called and will therefore only be `nil` if there truely is no
selected operation name:
https://github.com/rmosolgo/graphql-ruby/blob/v2.5.18/lib/graphql/query.rb#L115-L118
https://github.com/rmosolgo/graphql-ruby/blob/v2.5.18/lib/graphql/query.rb#L294-L299
Since `selected_operation_name` is safer than `operation_name`, we want
to use it everywhere.selected_operation_name over operation_name.1 parent fc60870 commit b30e088
2 files changed
Lines changed: 9 additions & 5 deletions
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
| 150 | + | |
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
109 | 113 | | |
110 | 114 | | |
111 | 115 | | |
| |||
0 commit comments