graphql-platform icon indicating copy to clipboard operation
graphql-platform copied to clipboard

[.NET 7] Investigate StringSyntaxAttribute for GraphQL strings

Open tobias-tengler opened this issue 2 years ago • 4 comments

Is your feature request related to a problem?

Some methods in the library accept GraphQL strings, e.g. AddDocumentFromString() or ExecuteAsync(). Currently there is no syntax highlighting / validation for these strings or any hint to "editors" that these are GraphQL strings.

The solution you'd like

I just found out about StringSyntaxAttribute which will be shipped with .NET 7 and support is already being rolled out in Visual Studio 2022 previews. It allows to annotate string arguments to hint to the "editor" what kind of string will be passed, so it can add syntax highlight and "editor only" validation of said string, for example for JSON or Regex strings. I thought it would be nice to also annotate our APIs accepting a GraphQL string with the StringSyntaxAttribute to hint at this being a GraphQL string. I marked this issue as "investigate", since I think it will be unlikely that Visual Studio adds GraphQL syntax highlighting. But since we already have the extension for StrawberryShake to highlight .graphql files, maybe we can take a similar route to support the StringSyntaxAttribute.

This is still really early, but I just wanted to note down the idea. I'm sure more resources around this will pop up until the .NET 7 release...

Product

Hot Chocolate

tobias-tengler avatar Feb 27 '22 14:02 tobias-tengler

Yes, already looked into this with @PascalSenn and @rstaib. We want to use this with HotChocolate but also with StrawberryShake. I think updating the language server should be easy.

Actually, looking at this, we were looking at the following Roslyn proposal: https://github.com/dotnet/csharplang/issues/4304

Which essentially provides functionality like the javascript template strings.

michaelstaib avatar Feb 28 '22 07:02 michaelstaib

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 04 '22 00:05 stale[bot]

Stale issue message

github-actions[bot] avatar Jul 03 '22 20:07 github-actions[bot]

I think I have now added this to a lot of places. I will do another round and then we can close this one.

michaelstaib avatar Jul 21 '22 21:07 michaelstaib

Hi, we couldn't find updates on this matter, so we decided to write a Visual Studio extension named GraphQLTools for GraphQL syntax highlighting. This extension highlights strings passed as arguments where the corresponding parameter is decorated with the StringSyntax attribute. Hope this helps.

gdifilippo-ca avatar Oct 27 '23 08:10 gdifilippo-ca