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.

Syntax Error: Unexpected EOF for dynamically created query

See original GitHub issue

Actual 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
    }
  }
`
Screen Shot 2019-10-22 at 2 19 38 PM

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:closed
  • Created 4 years ago
  • Reactions:9
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

17reactions
jaydensericcommented, Sep 29, 2020

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:

Screen Shot 2020-09-29 at 1 10 20 pm Screen Shot 2020-09-29 at 1 10 45 pm

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.

2reactions
acaocommented, Apr 28, 2022

I’ve added this feature in late december 2021, enjoy!

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is causing SyntaxError: Unexpected EOF error in ...
I am getting a SyntaxError: Unexpected EOF output when using an underscore template to render html in a Backbone application.
Read more >
[solved] SyntaxError: unexpected EOF while parsing
The Syntax error: unexpected EOF while parsing error means your code has reached the end block and you forgot to close the block...
Read more >
TCPE-357: DCM connection fails if the query has li...
Issue Receive various syntax errors on queries with lines commented out using – when using a connection set up through DCM.
Read more >
Dynamic SOQL Query Exception: : unexpected token: '&lt
When you use dynamic SOQL, you can't have an intervening space between the : and the variable after it. Change your code as...
Read more >
SQL Query with dynamic number of columns - Ask TOM
SQL Query with dynamic number of columns Hi Tom,I have a table like ... the code to parse your string: ops$tkyte@ORA920PC> create table...
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