-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add more customizable pattern for tag
#423
Comments
I agree "adding more complex tag pattern" . Because some GraphQL clients don't use template literal tag function. For example, with const { repository } = await graphql(
`
{
repository(owner: "octokit", name: "graphql.js") {
issues(last: 3) {
edges {
node {
title
}
}
}
}
}
`,
{
headers: {
authorization: `token secret123`,
},
}
); But I will not care TypeScript Template Literal Types pattern (e.g.
|
@Quramy about
I don't mean to actually infer type or whatever, just when you specify the pattern do not ignore ts types if they are matched by the pattern. I.e. here So yes, i agree that this plugin should not provide some types inference out of the box, but delegate it to some other third party libraries. However, it would be good to have autocomplete in such cases |
Thanks to TS new feature Template Literal Types it becomes possible to parse the query on type level, at least not complex one. However, it is not possible to get type of tagged literal because it is always
TemplateStringsArray
, but it is possible to use plain functions insteadgql('query { data }')
. So the correct types will be inferred in TS itself, and the autocomplete will be provided by this plugin.Also, it would be good to add possibility to provide autocomplete in types just as bonus for edge cases, i.e.
type Data = Query<'query { data }'>
It would be good to specify more complex pattern like start with
gql('
and ends with')
for functions and to cover case with types you could set start withQuery<'
and ends with'>
, or array of patterns. So we need just to specify the pattern which includes graphql content.I think it could close this issues as well
#117
#53
The text was updated successfully, but these errors were encountered: