Syntax Error: Unexpected EOF for dynamically created query
See original GitHub issueActual Behavior
I’m receiving the following error: Syntax Error: Unexpected <EOF>
when trying to use a javascript variable inside the gql template tag.
Expected Behavior
No error.
Steps to Reproduce the Problem Or Description
I’m not sure what version this changed in, but I noticed recently (after not working on this project for a little while and then coming back to it) that something had changed. Namely, it seems like autocomplete and validation against my actual GraphQL server started working / was added (without any changes from me), which is awesome by the way!! However, I don’t remember seeing any errors related to my javascript variable before this update.
import gql from 'graphql-tag'
import { perPage } from '../../config'
export const ALL_EVENTS_QUERY = gql`
query ALL_EVENTS_QUERY(
$where: EventWhereInput
$orderBy: EventOrderByInput
$skip: Int = 0
$first: Int = ${perPage}
) {
events(where: $where, orderBy: $orderBy, skip: $skip, first: $first) {
id
date
title
}
}
`
Also, this seems like it might be related to: https://github.com/apollographql/eslint-plugin-graphql/issues/156 ??
Specifications
- GraphQL for VSCode Extension Version: 0.2.2
- VSCode Version:
Version: 1.39.2
Commit: 6ab598523be7a800d7f3eb4d92d7ab9a66069390
Date: 2019-10-15T15:33:00.827Z
Electron: 4.2.10
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Darwin x64 19.0.0
- OS Name: MacOS
- OS Version: 10.15
Logs Of TS Server || GraphQL Language Service
I’m happy to provide either of these, but I’m not sure where to find them… Under the “Output” tab with “GraphQL Language Server”, I’m seeing nothing…
Issue Analytics
- State:
- Created 4 years ago
- Reactions:9
- Comments:16 (8 by maintainers)
Top GitHub Comments
This is a straight up bug. Just because an issue is tricky to fix, doesn’t mean it should be closed as
wontfix
.It’s the most basic way to include fragments in queries:
For people using fragments like this there is no choice but to either ignore the errors caused by this extension, or to uninstall the extension. The Apollo extension doesn’t display an error in this situation.
I’ve added this feature in late december 2021, enjoy!