Unexpected token f in JSON at position 1
See original GitHub issueHi.
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:
- Created 2 years ago
- Comments:11
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for tackling this. Appreciate your time.
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.