-
Notifications
You must be signed in to change notification settings - Fork 45
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 syntax highlighting to graphql-tools #52
Comments
@klis87 the
I'm not familiar with gqltools, but I don't think adding support for syntax-highlighting might not be trivial for this kind of code - this plugin will have to go through every template string in JS/JSX files and attempt to highlighted it as gql - I don't think that's possible with vscode. |
@kumarharsh It is possible because gql tags for react-apollo client are highlighted, so doing the same for typeDefs must be also possible. |
@klis87 - yes that is possible. But I feel like it can cause issues:
and not:
or any other variation?
Granted, the
but I feel that this convention doesn't cause clashes for the code below it. On the other hand, the But, I'm not aware of how the code for graphql-tools looks like, so maybe my reservations might not matter in reality. What are your thoughts? |
I agree with you that it might be dangerous to assume typeDefs convention. But would it be possible to make code highlighting configurable? for example as vscode setting like: {
"GQLCodeHighlitingPatterns": [
{
"path": "src/**/*.js",
"startTag": "const typeDefs = `",
"endTag": "`"
}
]
} Then it would be flexible and everyone could set things up to a specific tools/frameworks. |
I don't think vscode allows that. Because the syntaxes are defined in JSON, and the config file can't have a say in that. I think it'll be super hard to support it and still retain any amount of flexibility. |
I found a related issue on VSCode pertaining to this: microsoft/vscode#130 (comment) |
Ohhh, pity. So there is nothing what could we do? Could we add |
I'd prefer to wait for a better solution to this, or if more people are interested, then maybe we can figure out an approach which works best. One suggestion: you can write a simple tagged template function named gql, which just returns whatever is in the template. Then, you'll get the syntax highlighting too! |
Ok, so let's wait, Thank you for custom gql tag, this would actually work :) Btw, I guess this library won't work for dynamic types right? Which you set programatically. If that is so, would you consider adding ability to introspect schema from a graphql server endpoint? In a similar fashion like in apollo-codegen, which can generates flow types from graphql endpoint. |
Yes, that is one thing we might add (possibly). There is an open issue for apollo support in the gql library where you can give your inputs. |
Please add support for highlighting for graphql-tools, or add a settings like
EmbeddedQueryParser
in.gqlconfig
withstartTag
andendTag
to enable highlighting.The convention in graphql-tools is to declare types like this:
The text was updated successfully, but these errors were encountered: