Commit 05d64cc
update GraphQL parser to consume escaped characters
Summary:
### Context
We got [feedback](https://fb.workplace.com/groups/relay.support/permalink/25937328725889064/) in Relay Support about some generated artifacts being deleted in D54762067 (when `parseData` was declared in a variable outside the component specifically). It turns out that the RegEx syntax added in the diff was not being parsed correctly by the GraphQL extractor. So, the GraphQL source text was not extracted from the file and the generated artifact was removed.
## This diff
Adds logic to consume escaped characters. Note that comments and strings are already consumed generally.
I also changed the iterator to be peekable. The example application for this diff is in the regex `/text\/*/`: without peeking, `consume_identifier` consumes `text\` though `\` should be used as an escape.
It seems we've run into similar issues before which led us to consider switching to a stricter GraphQL parser (see e.g. D21256605 from 2020). Maybe we should revisit that idea?
Reviewed By: evanyeung
Differential Revision: D54879768
fbshipit-source-id: cccb3311acf7188b642c478f2a68f18d8d7eb66b1 parent 6b807a4 commit 05d64cc
File tree
2 files changed
+18
-6
lines changed- compiler/crates/extract-graphql
- src
- tests/extract/fixtures
2 files changed
+18
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
| 177 | + | |
177 | 178 | | |
178 | | - | |
| 179 | + | |
179 | 180 | | |
| 181 | + | |
180 | 182 | | |
181 | 183 | | |
182 | 184 | | |
| 185 | + | |
183 | 186 | | |
184 | 187 | | |
185 | 188 | | |
| |||
213 | 216 | | |
214 | 217 | | |
215 | 218 | | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
216 | 223 | | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
222 | 228 | | |
| 229 | + | |
223 | 230 | | |
224 | 231 | | |
225 | 232 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
0 commit comments