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

feature: implement elixir support based only on sigils #50

Closed
wants to merge 1 commit into from

Conversation

pmargreff
Copy link

@pmargreff pmargreff commented Nov 18, 2021

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 empty gql function if the devs want to use vscode-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 makes vscode-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

vscode-elixir-with-sigils

┆Issue is synchronized with this Jira Task by Unito

@apollo-cla
Copy link

@pmargreff: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

@pmargreff
Copy link
Author

pmargreff commented Nov 19, 2021

Putting it on hold, seems like Elixir does not allow users to define a sigil with multiple chars. I will try to make that happen in Elixir lang first then I will be back to this PR. 😢

@pmargreff pmargreff closed this Jun 3, 2022
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.

2 participants