feature: implement elixir support based only on sigils #50
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey, first of all, thank you for the tooling. Apollo has been an excellent tool in the GraphQL ecosystem 🙇🏾 . In this PR, I'm adding an alternative syntax for using
vscode-graphql
with Elixir, some context why:Context
The original implementation requires the GraphQL block to be wrapped in a
gql
function. That forces users to define an emptygql
function if the devs want to usevscode-graphql
features even with no utility. I took a look at the original PR (apollographql/apollo-tooling#1304), and it was intentional. It seems like the original author had this pattern already defined in his codebase.Solution
One option is to use sigils for improving it. Sigils also allow heredocs, and heredocs is how
vscode-graphql
supports ruby (apollographql/apollo-tooling#1304).By default, elixir allows users to use
~s"""...
for strings without interpolation and~S"""...
for cases where string interpolation or escaping is needed. Elixir is a very extensible language, allowing users to write their own sigils. This implementation makesvscode-graphql
shine when users have defined sigils in a heredoc style for graphql operations.Once users may be using the original format, I kept that working together with the new syntax support. I also added basic tests to ensure things are still working for the version based on function and the version based on sigils.
Screenshots
┆Issue is synchronized with this Jira Task by Unito