Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toGraphQL gets null type for enum variable #1256

Closed
papigers opened this issue Jul 3, 2016 · 4 comments · May be fixed by X-oss-byte/next.js#1421
Closed

toGraphQL gets null type for enum variable #1256

papigers opened this issue Jul 3, 2016 · 4 comments · May be fixed by X-oss-byte/next.js#1421

Comments

@papigers
Copy link

papigers commented Jul 3, 2016

I'm using isomorphic-relay, and I'm encountering some problem, which you can read about in more details here.

The relevant part for you, is that I saw the server's preloaded data looks like this:

...
...
{
          "children": [
            {
              "calls": [
                {
                  "kind": "Call",
                  "name": "orderBy",
                  "metadata": {
                    "type": null
                  },
                  "value": {
                    "kind": "CallValue",
                    "callValue": "TRENDING"
                  }
                },
                {
                  "kind": "Call",
                  "name": "first",
...
...

Here you can see that the type of orderBy is null, instead of PollSort, an enum type.

The above snippet is, as mentioned, part of the preloaded data the server passed to the client. This is done in this file: prepareData.js. The relevant line is:

data.push({ query: toGraphQL.Query(request.getQuery()), response });

So the root of the problem is actually that toGraphQL.Query returns null for my input variable type.

Any idea how can this be fixed?

@josephsavona
Copy link
Contributor

josephsavona commented Jul 3, 2016

Thanks for filing such a detailed issue. It looks like callsToGraphQL isn't passing the call type to QueryBuilder.createCall. Care to send a PR to fix?

@papigers
Copy link
Author

papigers commented Jul 3, 2016

I'd be happy to, but I'm a bit of a newbie to this repo, and relay in general. How can I get the call type from callsToGraphQL?

@papigers
Copy link
Author

papigers commented Jul 3, 2016

Oh it's simply an attribute of Call. I'll try to fix this as soon as I get home.

papigers added a commit to papigers/relay that referenced this issue Jul 3, 2016
Currently types are ignored and not getting passed in `callsFromGraphQL`
or `callsToGraphQL`.
This results in dangerous output in `toGraphQL`, in which all calls have
type null. This can cause problems when using non-scalar types (like
enum).
Example can be found
[here](facebook#1256).
@papigers
Copy link
Author

papigers commented Jul 3, 2016

Done. #1257, though there are some build errors...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants