Skip to content

[.NET 7] Investigate StringSyntaxAttribute for GraphQL strings #4800

@tobias-tengler

Description

@tobias-tengler

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

Metadata

Metadata

Assignees

No one assigned
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions