-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] fix: fix block string parsing in language parser #1777
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1777 +/- ##
==========================================
+ Coverage 65.72% 66.40% +0.68%
==========================================
Files 85 86 +1
Lines 5091 5153 +62
Branches 1607 1643 +36
==========================================
+ Hits 3346 3422 +76
- Misses 1718 1727 +9
+ Partials 27 4 -23 Continue to review full report at Codecov.
|
awesome, thank you for starting on this! i’ll have to take a closer look later. this parser is designed to handle inline and multiline graphql strings the same. in terms of tracking data within rules, steps are the best way to do that. the change you made to |
4fa9ca3
to
1c11938
Compare
62 files changed. Are all the changes in this PR related to fixing the block string parsing? It's hard to review the changes with such a large changeset. Might have something to do with the conflict in this branch too. |
@imolorhe it's my bad, I had to do some last few force pushes to main branch before we switched to @dwwoelfel I can take care of rebasing it for you if you like? |
@acao Oh okay, that explains it. |
I'll rebase against master and force push. |
19d80be
to
026d29f
Compare
🦋 Changeset detectedLatest commit: 79382a5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
026d29f
to
6b86b9e
Compare
The changes have been rebased. |
thank you for taking care of that so quickly @dwwoelfel ! hoping to take a look later |
@dwwoelfel on closer inspection, everything appears to be working as designed! excellent work you are correct that this is a hack in terms of design, and a clever one. we can easily implement all of this in
MultilineStringValue: [p('"""'), 'StringValue', p('"""')],
Value(token: Token) {
switch (token.kind) {
...
case 'MultilineString':
return 'MultilineStringValue';
}
} |
@acao I don't think that approach can work for multiple lines in a block string. The approach works for rules like With a multiline block string, there is no way for the logic in Rules.js to consume the stream and advance to the next line. Looking at the python codemirror mode, which also has multiline strings delimited by triple-quotes, they set a |
@dwwoelfel that sounds like a great idea! |
@dwwoelfel would you recommend your change as-is to fix block string parsing? |
@ajbouh The patch was fully functional when I created the PR. I think it's fine as-is, but an approach that uses a |
This is an attempt to fix block string support in GraphiQL.
The goal is to make a query like the following parse properly in GraphiQL:
It seems like there shouldn't be logic about how block strings are constructed in
onlineParser.ts
, but I'm having a hard time keeping that knowledge solely inRules.ts
. I'm finding it very tricky to write any logic that requires information from the previous line.