Closed Axxxx0n closed 1 month ago
I think the g:graphql_javascript_functions = ["graphql"]
approach would be the best way to handle this.
I just want to be sensitive to the number of optimistic matches we apply to JavaScript buffers in attempts to find embedded GraphQL strings.
We also already support a "magic" comment within the GraphQL template string:
const query = graphql(`# graphql
query ExampleQuery {
example {
id
}
}
`)
I'm going to close this because I think it's a sufficiently good solution that doesn't involve additional code and runtime pattern matching, but please reopen if anyone feels otherwise.
We also already support a "magic" comment within the GraphQL template string
This works as long as everybody on your team uses this plugin and/or is OK with updating documents to add this spurious comment.
What if you contribute to a project where you don't have the option of making these refactors?
@jparise would you be open to a PR adding g:graphql_javascript_functions = ["graphql"]
? Adding the comment is suboptimal for the reasons @felamaslen gave above. i'd be happy to contribute to the implementation, just don't want to waste my time if you don't want it.
Yes, I'm happy to review a change that implements something like that. I think if the default is just ["graphql"]
that it shouldn't introduce much overhead beyond the current implementation.
I somewhat regret that g:graphql_javascript_tags
defaults to all of ['gql', 'graphql', 'Relay.QL']
because it makes the pattern match slightly more expensive for everyone.
@dickfickling @felamaslen I added initial support for the graqhql()
function in #109. If you have a chance to check it out, I'd be glad to know if it addressed your use cases.
Looks good! I saw an error in the vim log related to vim-graphql
once right after updating the plugin, but I skipped it and haven't seen it since. I'll report back here if I see it again!
Looks good! I saw an error in the vim log related to
vim-graphql
once right after updating the plugin, but I skipped it and haven't seen it since. I'll report back here if I see it again!
Thanks! If it flashes by again, you should be able to see it in :messages
.
New graphql codegen client preset is not using template strings for graphql queries. It uses
graphql()
function with string arguments. Using this we don't get syntax highlighting.Possible solutions:
Similar to
g:graphql_javascript_tags
option we could use something asg:graphql_javascript_function=["graphql", "gql"]
and mark the string inside function for syntax highlightingUse magic comment as many graphql tools and extensions do:
let g:graphql_javascript_tags = ["gql", "graphql", "Relay.QL", "gql(", "graphql("]
Vim Version