question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

String interpolation in enum definition is marked as incorrect

See original GitHub issue

Version 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 '$'.

Screen Shot 2019-10-14 at 10 24 01 PM

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:open
  • Created 4 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

1reaction
benamscommented, Jun 22, 2021

same problem here, it hurts that queries cannot be dynamic

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found