String interpolation in enum definition is marked as incorrect
See original GitHub issueVersion and Environment Details
Operation system: macOS Mojave 10.14.6
IDE name and version: Webstorm 2019.2.3
Plugin version: 2.2.0
Expected Behaviour
The following code snippet:
gql`
enum FooTypes { ${"foo bar"} }
`
should be interpreted as correct by the plugin, seeing as this is syntactically correct when declaring a graphql schema inside a JS file.
Actual Behaviour
The plugin displays an error stating <enum value definition> expected, got '$'
.
Having a schema enum match the JS equivalent is pretty useful for having a single source of truth for specific constants and seeing the IDE mark it as incorrect is somewhat annoying. String interpolation is correctly interpreted in other scenarios I’ve come across, so I guess this just might have been missed.
Steps to Reproduce / Link to Repo with Reproduction and Instructions
import { gql } from 'apollo-server';
const arrayOfThings = ["foo", "bar"];
const schema = gql`
enum FooTypes { ${arrayOfThings.join(' ')} }
`;
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7
Top Results From Across the Web
String interpolation in enum definition is marked as incorrect
String interpolation is a bit of a grey area given that the GraphQL spec doesn't cover templating such as string interpolation using JS...
Read more >Associating string representations with an Enum that uses ...
It seems that the issue is that an Enum will use all class variables as the enum values, which causes them to return...
Read more >Enum case and String interpolation is not very safe: can ...
The fact that the default string representation of an enum case is not rawValue is not unsafe. This behavior is not always what...
Read more >Enum Class (System) - Microsoft Learn
For example, do not define an enumerated constant that merely marks the end of the enumeration. If you need to determine the last...
Read more >My son in University got marked down for putting an enum in ...
I might have a static definitions class with several enums in there, ... public class OuterClass { public string FooBar() { //do stuff...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
same problem here, it hurts that queries cannot be dynamic
See also https://github.com/jimkyndemeyer/js-graphql-intellij-plugin/issues/417#issuecomment-972212486