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

Custom GraphQL template tag #8738

Closed
jasonkuhrt opened this issue Jul 11, 2020 · 3 comments
Closed

Custom GraphQL template tag #8738

jasonkuhrt opened this issue Jul 11, 2020 · 3 comments
Labels
area:multiparser Issues with printing one language inside another, like CSS-in-JS lang:graphql Issues affecting GraphQL lang:javascript Issues affecting JS locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:enhancement A potential new feature to be added, or an improvement to how we print something

Comments

@jasonkuhrt
Copy link

This may be considered a dupe of #4260, because one of the solutions there would satisfy this issue too.

I work on a project called Nexus and we're considering integrating ts-graphql-plugin. It allows for static analysis of GraphQL strings, e.g. queries. One of its features is to allow customizing the template tag that it will analyze.

Relevant to Nexus because our desired API would not use gql as the tag name, but rather ctx.client.send (at least currently).

However, it appears that this path would lose us formatting from prettier.

So the feature request here is to allow local prettier configuration that would make it so a custom tag/path such as ctx.client.send could be treated as GraphQL source to format.

A solution taken from #4260 that could work for this, adapted:

{
  "overrides": [
    {
      "tags": ["ctx.client.send"],
      "options": { "type": "graphql" }
    }
  ]
}
@jasonkuhrt
Copy link
Author

jasonkuhrt commented Jul 12, 2020

Interested in providing a PR for this. Only place I found a reference to gql tag in codebase (non-test) was here:

(ast.tag.name === "gql" ||

Is this right?

@bakkot
Copy link
Collaborator

bakkot commented Jul 13, 2020

See also #5588 (comment), #4424, #7073, and #6626 (and possibly others).

I think most of the work to be done here is design, not implementation. If you want to try to pick up and drive discussion of the design, go for it. (But I recommend opening an issue on that topic, or commenting on an existing one, rather than just submitting a PR with a particular design already implemented.)

@thorn0 thorn0 added area:multiparser Issues with printing one language inside another, like CSS-in-JS lang:graphql Issues affecting GraphQL lang:javascript Issues affecting JS type:enhancement A potential new feature to be added, or an improvement to how we print something labels Jul 14, 2020
@thorn0
Copy link
Member

thorn0 commented Aug 27, 2020

Closing in favor of #5588.

@thorn0 thorn0 closed this as completed Aug 27, 2020
@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Nov 26, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area:multiparser Issues with printing one language inside another, like CSS-in-JS lang:graphql Issues affecting GraphQL lang:javascript Issues affecting JS locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:enhancement A potential new feature to be added, or an improvement to how we print something
Projects
None yet
Development

No branches or pull requests

3 participants