Skip to content
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

move parser into its own module #792

Merged
merged 11 commits into from
Nov 19, 2021
Merged

Conversation

performantdata
Copy link
Contributor

Fixes #466. Based on PR #790.

@performantdata
Copy link
Contributor Author

performantdata commented Nov 13, 2021

@yanns Where do you think StringUtil.blockStringValue should go? Rip out a copy into the parser module? It only appears to be used there. Then deprecate in core, 2.x branch?

@yanns
Copy link
Contributor

yanns commented Nov 13, 2021

@yanns Where do you think StringUtil.blockStringValue should go? Rip out a copy into the parser module? It only appears to be used there. Then deprecate in core, 2.x branch?

Yes we can move it into the parser module.
To avoid breaking changes, we can keep StringUtil.blockStringValue calling the implementation in the parser module.

@yanns
Copy link
Contributor

yanns commented Nov 13, 2021

You can rebase on main and force-push it now.

build.sbt Show resolved Hide resolved
@performantdata
Copy link
Contributor Author

calling the implementation in the parser module

I'm making that private, so just leaving the full implementation in StringUtil. None of the other Sangria core code is using blockStringValue, so at this point it's a method that we provide for our users? That seems unlikely. I suspect that it was only ever intended for the parser, so I would deprecate it.

@performantdata performantdata force-pushed the issue/466 branch 2 times, most recently from d5cbb0f to 526fed4 Compare November 13, 2021 20:40
@performantdata performantdata marked this pull request as ready for review November 13, 2021 22:09
@performantdata
Copy link
Contributor Author

leaving the full implementation in StringUtil. None of the other Sangria core code is using blockStringValue, so at this point it's a method that we provide for our users? That seems unlikely. I suspect that it was only ever intended for the parser, so I would deprecate it.

Should I delete this method in this PR? and deprecate it in 2.x?

@performantdata
Copy link
Contributor Author

Should I deprecate the QueryParser members in the 2.x branch? I made them private[this] or protected, and sealed the traits. I assume not, since I assume that no one is using them directly.

@yanns
Copy link
Contributor

yanns commented Nov 15, 2021

Should I deprecate the QueryParser members in the 2.x branch? I made them private[this] or protected, and sealed the traits. I assume not, since I assume that no one is using them directly.

no I'd not do that.
What is the intended purpose of using sealed traits? Do you want to make sure that no one is using those traits outside the sangria parsed?

@yanns
Copy link
Contributor

yanns commented Nov 15, 2021

leaving the full implementation in StringUtil. None of the other Sangria core code is using blockStringValue, so at this point it's a method that we provide for our users? That seems unlikely. I suspect that it was only ever intended for the parser, so I would deprecate it.

Should I delete this method in this PR? and deprecate it in 2.x?

I think that this implementation should be moved to its own class as it's something present in the specs: http://spec.graphql.org/October2021/#sec-String-Value.Block-Strings

The existing tests should be also extracted in a separated class.

And StringUtil.blockStringValue should call this implementation.

@performantdata
Copy link
Contributor Author

Should I deprecate the QueryParser members in the 2.x branch? I made them private[this] or protected, and sealed the traits. I assume not, since I assume that no one is using them directly.

no I'd not do that.

OK, so I won't "deprecate the QueryParser members in the 2.x branch".

What is the intended purpose of using sealed traits? Do you want to make sure that no one is using those traits outside the sangria parsed?

Right. Since I'm assuming also that no one is currently using the traits directly, I see no reason to make them part of the usable public API. That would restrict our freedom to refactor.

It also might buy some performance, depending on the assumptions that the compiler makes. I know that works for visibility: private[this] is usually inlined.

@performantdata
Copy link
Contributor Author

performantdata commented Nov 16, 2021

I think that this implementation should be moved to its own class as it's something present in the specs

And StringUtil.blockStringValue should call this implementation.

But are you sure that anyone's using it? I don't see it being called from open source Scala code on GitHub. Deprecating the method and seeing who complains might make more sense than needlessly exposing parser internals.

(I made the changes locally, but paused on this thought before committing.)

@yanns
Copy link
Contributor

yanns commented Nov 17, 2021

I think that this implementation should be moved to its own class as it's something present in the specs

And StringUtil.blockStringValue should call this implementation.

But are you sure that anyone's using it? I don't see it being called from open source Scala code on GitHub. Deprecating the method and seeing who complains might make more sense than needlessly exposing parser internals.

(I made the changes locally, but paused on this thought before committing.)

Yes, we can deprecate StringUtil.blockStringValue.

performantdata and others added 9 commits November 17, 2021 08:58
Users of this parser library probably don't need this API.

Also copies some StringUtil methods into the parser code.  Adds the
`parser` project to the `root` target's aggregate.
Shapeless was removed in parboiled2 upstream.
Avoid depending on it directly for an easier upgrade path.
It's believed that this method is unused outside of the parser.

Moves the parser's copy of the implementation from the `Tokens` trait
into a new `Lexical` object, from which it can be easily made visible if
needed in the future.  Moves the tests over from `core` into `parser`.

Also fixes some IDE warnings.
@performantdata
Copy link
Contributor Author

performantdata commented Nov 17, 2021

Anything else? Do we want to make sangria-parser a Java 9 module? (The purpose of doing that would be the same: ensure that visibility is restricted to a desired-public API.)

Actually, I should hold off on that. I don't know enough to make that happen quickly.

Copy link
Contributor

@yanns yanns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've run this version with some applications, and no issues detected!
👍

@yanns
Copy link
Contributor

yanns commented Nov 19, 2021

Anything else? Do we want to make sangria-parser a Java 9 module? (The purpose of doing that would be the same: ensure that visibility is restricted to a desired-public API.)

Actually, I should hold off on that. I don't know enough to make that happen quickly.

Yes, it's something we can add later if we need.

@yanns yanns merged commit ab523db into sangria-graphql:main Nov 19, 2021
@performantdata performantdata deleted the issue/466 branch November 23, 2021 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Split sangria parse and AST into separate module
2 participants