Closed ksdc-vaughann closed 2 weeks ago
@ksdc-vaughann hi! Thank you for bringing up the issue. Unfortunately, I don't think it will ever be fixed. GraphQL parser is not and can't be aware of any string-building methods in every possible language. For instance, Java also has MessageFormat
API, e.g.
MessageFormat.format(
"At {1,time} on {1,date}, there was {2} on planet {0,number,integer}.",
planet, new Date(), event);
Should the GraphQL parser be able to handle that too?
It’s generally much better to use GraphQL variables for this purpose, and that’s how most users approach it. There are several discussions on StackOverflow that cover this topic. For example, this answer mentions:
If your query is dynamically generated, there's no way to do static analysis on it using tools like eslint-plugin-graphql, so you can't check if your query is valid without actually running your code.
This is one of the key reasons for using variables instead of interpolation - and it’s likely the issue you’re currently encountering.
Describe the bug When using a text block (annotated as GraphQL) as a template for a GraphQL mutation, intellisense flags unquoted string variables (like %s & %d) as unresolved values.
To Reproduce Create the following text block in Java with the IntelliJ GraphQL plugin installed: ` java
`
GQL Schema
input HeroInput { name: String, born: LocalDate, damage: Float }
type Hero { name: String, born: LocalDate, age: Int, damage: Float }
Expected behavior The expectation is that there should not be an inspection warning of " expected, got '%'
Unknown field "d" on input type "HeroInput"
Version and Environment Details Operation system: Windows 11 Build 22631.4169 IDE name and version: IntelliJ IDEA 2024.2.1 (Ultimate Edition) Plugin version: 242.21829.3