-
Notifications
You must be signed in to change notification settings - Fork 103
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
Support /* GraphQL */ comment tags #224
Comments
In the meantime, import gql from 'fake-tag'
const query = gql`
{
viewer {
id
}
}
` |
i agree - short-term it’d make sense to update the readme until the comment
feature is added.
…On Wed, Apr 24, 2019 at 5:40 PM Jayden Seric ***@***.***> wrote:
In the meantime, fake-tag <https://github.com/jaydenseric/fake-tag> is a
better solution than the copy-paste code suggested in the readme:
import gql from 'fake-tag'
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#224 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAIRCRUXW6CC4IY6WAXF5FTPSD4XZANCNFSM4HHBBGVQ>
.
|
This PR improves the identity template literal tag docs: - Tweaked the text from saying tags are “always” used in Apollo projects to “often”, as there are situations where tags are not necessary like when making server side queries via `node-fetch` that come up in real world projects. - Replaced the manual copy paste fake tag code with the suggestion to use [`fake-tag`](https://npm.im/fake-tag). This utility is easy to install and use and has tests covering Interpolations and escapes. It has been reasonably battle tested. - Mentioned the `/* GraphQL */` comment tag enhancement issue (#224). See earlier discussion: #224 (comment) Co-authored-by: Jon Wong <[email protected]>
Is this being worked on? |
Any news about this feature ? |
For anyone who does not want an additional dependency, you can just do
And then just use gql as you normally would. Your editor and this plugin will recognize it with no issues.
|
@rigelglen see the
|
Would be really nice to have it since usage of template strings is not possible when using the @jaydenseric do you have plans to support gql functions like I read through the docs but can't find a working solution except for patching the visitor. |
@taletski I'm not sure exactly what you mean. Which repo/package are you referring to? |
@jaydenseric sorry for providing a little context. I am using This tool goes over Example: #schema.graphql
type Queries {
backendQuery(foo: String!): BackendQueryResponse
}
type BackendQueryResponse {
foo: String
bar: String
} // queries.ts
import { gql } from 'my-codegen-setup/generated/gql.ts'
// note that I am querying only `foo`, but not `bar`
const MY_QUERY = gql(`
query myQuery($foo: String!) {
result: backendQuery(foo: $foo) {
bar
}
}
`) // Component.tsx
const { data } = useQuery(MY_QUERY, { variables: { foo: 'test'} });
// ^ ^^^^^^^^^
// | |
// | - Variables are now strictly typed, TS will not allow me to omit required ones
// - Type of `data` is { result: { bar?: string } } In the example above the caveat is that the generated For now, So my questions is, do you plan to support the |
Support it in what repo/package? If you mean |
@jaydenseric sorry for confusion. I think I should proceed with a feature request and/or a PR on my own for that |
This library is no longer maintained |
Like mentioned in the docs, a lot of GraphQL clients (such as
graphql-react
) don't need a template string tag. Such untagged template literals can be marked with a leading/* GraphQL */
comment for syntax highlighter, linters, and other tools.This is a superior solution to a fake tag, which inconveniently needs to be imported everywhere and causes unnecessary bundle size and performance overheads.
The text was updated successfully, but these errors were encountered: