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.

JSON scalar types not supported

See original GitHub issue

Bug description

I have an upstream graphql server that uses JSON scalar types.

When the value returned for this scalar is a JSON object, wundergraph complains with the following error:

2022-12-14T13:53:48+11:00 ERROR apihandler/apihandler.go:801 ResolveGraphQLResponse {"component": "@wundergraph/node", "reqId": "44a4ae5f-ef82-a2e9-3731-7a0284accd0b", "error": "invalid value type 'object' for path /data/bar, expecting string, got: {\"type\":\"string\"}. You can fix this by configuring this field as Int/Float Scalar"}
github.com/wundergraph/wundergraph/pkg/apihandler.(*GraphQLHandler).ServeHTTP
        /home/runner/work/wundergraph/wundergraph/pkg/apihandler/apihandler.go:801
github.com/wundergraph/wundergraph/pkg/authentication.NewCSRFMw.func1.1
        /home/runner/work/wundergraph/wundergraph/pkg/authentication/authentication.go:864
net/http.HandlerFunc.ServeHTTP
        /opt/hostedtoolcache/go/1.18.8/x64/src/net/http/server.go:2084
github.com/wundergraph/wundergraph/pkg/authentication.NewLoadUserMw.func1.1
        /home/runner/work/wundergraph/wundergraph/pkg/authentication/authentication.go:655
net/http.HandlerFunc.ServeHTTP
        /opt/hostedtoolcache/go/1.18.8/x64/src/net/http/server.go:2084
github.com/rs/cors.(*Cors).Handler.func1
        /home/runner/go/pkg/mod/github.com/rs/cors@v1.7.0/cors.go:219
net/http.HandlerFunc.ServeHTTP
        /opt/hostedtoolcache/go/1.18.8/x64/src/net/http/server.go:2084
github.com/wundergraph/wundergraph/pkg/apihandler.(*Builder).BuildAndMountApiHandler.func4.1
        /home/runner/work/wundergraph/wundergraph/pkg/apihandler/apihandler.go:233
net/http.HandlerFunc.ServeHTTP
        /opt/hostedtoolcache/go/1.18.8/x64/src/net/http/server.go:2084
github.com/wundergraph/wundergraph/pkg/apihandler.logRequestMiddleware.func1.1
        /home/runner/work/wundergraph/wundergraph/pkg/apihandler/apihandler.go:353
net/http.HandlerFunc.ServeHTTP
        /opt/hostedtoolcache/go/1.18.8/x64/src/net/http/server.go:2084
github.com/gorilla/mux.(*Router).ServeHTTP
        /home/runner/go/pkg/mod/github.com/gorilla/mux@v1.8.0/mux.go:210
net/http.serverHandler.ServeHTTP
        /opt/hostedtoolcache/go/1.18.8/x64/src/net/http/server.go:2916
net/http.(*conn).serve
        /opt/hostedtoolcache/go/1.18.8/x64/src/net/http/server.go:1966

How to reproduce

I have been able to create a self-contained wundergraph project to reproduce the error, using the in-built graphql server. It is attached: wgtest.zip

To reproduce:

  • install dependencies with yarn
  • run with yarn start

Then visit the following URL: http://localhost:9991/operations/Hello

Expected behavior

The response from the server should be successfully returned to the caller.

For the attached project, that is: { "data": {"bar": {"type": "string"}} }

WunderGraph information

Included in the attached project

Environment & setup

  • OS: Mint w/kernel 5.4.0-135-generic
  • Go version: go version go1.13.8 linux/amd64
  • Node.js version: v18.12.1

WunderCtl Version

119.1

Issue Analytics

  • State:open
  • Created 9 months ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jensneusecommented, Dec 19, 2022

We know the solution and are currently implementing it.

0reactions
greemocommented, Dec 15, 2022

I also encounter the same problem when the graphql server returns an JSON int literal for the value.

2022-12-15T16:57:10+11:00 ERROR apihandler/apihandler.go:2257 ResolveGraphQLResponse failed {"component": "@wundergraph/node", "operationName": "myOperation", "operationType": "QUERY", "error": "invalid value type 'number' for path /data/somewhere/value, expecting string, got: 0. You can fix this by configuring this field as Int/Float Scalar"}
Read more comments on GitHub >

github_iconTop Results From Across the Web

support JSON scalar type #32 - shurcooL/graphql - GitHub
I have a JSON type and it seems to be expecting the whole object before running my unmarshal. is there any way to...
Read more >
JSON type not supported. (Parameter 'ValueKind')\r\nActual ...
it comes from the Gremlin client as System.Linq.Enumerable.SelectEnumerableIterator<System.Text.Json.JsonElement, object> which my method ...
Read more >
JSON Data Types - W3Schools
Valid Data Types. In JSON, values must be one of the following data types: a string; a number; an object (JSON object); an...
Read more >
What data types are supported by JSON? - Educative.io
What data types are supported by JSON? · String · Number · Boolean · Null · Arrays · Object.
Read more >
JSON format properties and data type conversions - IBM
JSON supports a value of type String, Number and Boolean. It does not support octal and hexdecimal values. The data handler will delegate...
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