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.

Unexpected token f in JSON at position 1

See original GitHub issue

Hi.

Seems like I’m getting a very similar issue as in https://github.com/anvilco/spectaql/issues/83, but it should’ve been resolved on 16 Sep 2021

I’m getting the following error:

➜  nestjs git:(staging) ✗ npx spectaql -d spectaql-config.yml
undefined:1
{first: 10}
 ^

SyntaxError: Unexpected token f in JSON at position 1

Schema: schema.txt

Config:

introspection:
  schemaFile: ./schema.gql

info:
  title: GraphQL API Reference
  description: Welcome to the party!
  termsOfService: https://www.example.com/terms
  contact:
    name: API Support
    url: http://www.example.com/support
    email: support@example.com
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html

Anything I’m doing wrong? Or anything I’m missing?

Full stack trace:

➜  nestjs git:(staging) ✗ npx spectaql -d spectaql-config.yml
undefined:1
{first: 10}
 ^

SyntaxError: Unexpected token f in JSON at position 1
    at JSON.parse (<anonymous>:null:null)
    at Object.resolveDefaultValue (/path/to/spectaql/node_modules/graphql-2-json-schema/dist/lib/reducer.js:64:21)
    at introspectionFieldReducer (/path/to/spectaql/node_modules/graphql-2-json-schema/dist/lib/reducer.js:38:46)
    at arrayReduce (/path/to/spectaql/node_modules/lodash/lodash.js:697:21)
    at Function.reduce (/path/to/spectaql/node_modules/lodash/lodash.js:9749:14)
    at introspectionFieldReducer (/path/to/spectaql/node_modules/graphql-2-json-schema/dist/lib/reducer.js:26:46)
    at arrayReduce (/path/to/spectaql/node_modules/lodash/lodash.js:697:21)
    at Function.reduce (/path/to/spectaql/node_modules/lodash/lodash.js:9749:14)
    at /path/to/spectaql/node_modules/graphql-2-json-schema/dist/lib/reducer.js:77:34
    at arrayReduce (/path/to/spectaql/node_modules/lodash/lodash.js:697:21)
    at Function.reduce (/path/to/spectaql/node_modules/lodash/lodash.js:9749:14)
    at Object.fromIntrospectionQuery (/path/to/spectaql/node_modules/graphql-2-json-schema/dist/lib/fromIntrospectionQuery.js:30:30)
    at jsonSchemaFromIntrospectionResponse (/path/to/spectaql/app/spectaql/graphql-loaders.js:90:20)
    at module.exports (/path/to/spectaql/app/spectaql/index.js:110:22)
    at loadData (/path/to/spectaql/app/index.js:172:95)
    at module.exports (/path/to/spectaql/app/index.js:176:80)
    at Object.<anonymous> (/path/to/spectaql/bin/spectaql.js:74:1)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
jcunacommented, Mar 4, 2022

@jcuna fixed and published in 0.14.0…thanks for your patience!

Thank you for tackling this. Appreciate your time.

1reaction
newhousecommented, Feb 5, 2022

In my case, It actually works with a previous version of the schema.gql file. So there must be something that Apollo is actually adding to the output gql file that is not compatible with graphql-2-json-schema. All my tools currently mark the .gql file as valid. I’ll keep digging and will update back.

Can you provide the 2 files - 1 that works and 1 that does not?

I’m pretty sure that graphql-to-json-schema simply is not expecting / supporting what it’s encountering because it’s a bug there. This type of thing has come up before.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix 'Unexpected token o in json at position 1' - STechies
JavaScript programmers have encountered the “unexpected token o in json at position 1” at some point in their lives. This error is raised...
Read more >
Error "Uncaught SyntaxError: Unexpected token with JSON ...
In my case, Grails 2.5.6 rendered render ([key: value]) with single quotes, leading to the JSON parseError at position 1 in jquery Ajax....
Read more >
Unexpected token o in JSON at position 1 error in JS
The "Unexpected token o in JSON at position 1" error occurs when we try to JSON.parse a value that is not a valid...
Read more >
What Is JSON and How to Handle an “Unexpected Token” Error
Learn what JSON is and how you can deal with errors occurring when parsing JSON data, such as "Unexpected Token < in JSON...
Read more >
`SyntaxError: Unexpected token f in JSON at position 1` when ...
SyntaxError: Unexpected token f in JSON at position 1 when sending gzipped post request bodies using fetch() #2009.
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