Skip to content

[language-service] parsing error for string template variables in a "default argument value" position #2787

Open
@ezracelli

Description

@ezracelli

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I'd love to be able to extract default argument values into constants, so I can:

  • avoid "magic values" in the schema
  • use the constant default values inside other functions

This is the pattern I'd like to implement:

const schema = gql`
  type ImageAsset {
    src(
      height: Int
      width: Int = ${DEFAULT_WIDTH}
    ): ImageSource!
  }
`;

... which unfortunately leads to a parsing error: Syntax Error: Unexpected ")".

image

image

Expected Behavior

vscode-graphql should understand that this is, at the very least, "some default value" (understandable that it probably won't be able to grab the exact value — that would be pretty awesome, though!)

Steps To Reproduce

const schema = gql`
  type ImageAsset {
    src(
      height: Int
      width: Int = ${DEFAULT_WIDTH}
    ): ImageSource!
  }
`;

Environment

- VSCode extension `graphql.vscode-graphql` Version: 0.7.5
- OS: MacOS Ventura (13.0 Beta, build 22A5352e)

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions