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

Pass call type in from/toGraphQL #1257

Closed
wants to merge 6 commits into from

Conversation

papigers
Copy link

@papigers papigers commented Jul 3, 2016

Currently types are ignored and not getting passed in callsFromGraphQL
or callsToGraphQL.
This results in dangerous output from toGraphQL, in which all calls have
type null. This can cause problems when using non-scalar types (like
enum).
For more details see #1256.

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).
@ghost
Copy link

ghost commented Jul 3, 2016

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks!

@ghost
Copy link

ghost commented Jul 3, 2016

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@ghost ghost added the CLA Signed label Jul 3, 2016
@@ -42,7 +43,11 @@ function callsFromGraphQL(
const orderedCalls = [];
for (let ii = 0; ii < callsOrDirectives.length; ii++) {
const callOrDirective = callsOrDirectives[ii];
let {value} = callOrDirective;
let {value, metadata} = callOrDirective;
let type = undefined;
Copy link
Contributor

@josephsavona josephsavona Jul 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let type: ?string;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@josephsavona
Copy link
Contributor

josephsavona commented Jul 3, 2016

@papigers Thanks for the PR! Be sure to run the tests locally; that's what is failing in the build. Some tests look at the actual shape of the "concrete" query which will be different after this PR, so those tests will need to be updated. If there's a test failure that isn't as obvious, feel free to comment here and we can help.

@papigers
Copy link
Author

papigers commented Jul 3, 2016

@josephsavona Will do, working on that right now, sorry for this noobish PR.

Next time will be better, I hope ;)

@papigers
Copy link
Author

papigers commented Jul 3, 2016

Sorry for the uninformatives commits

@@ -23,7 +23,7 @@ import type RelayQuery from 'RelayQuery';

export type Call = {
name: string,
type?: string,
type?: ?string,
Copy link
Contributor

@steveluscher steveluscher Jul 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't thought about this as deeply as you two have, but might we instead want type to either be a string or not supplied?

const orderedCall = {
  name: callOrDirective.name, 
  value,
};
if (metadata && metadata.type) {
  orderedCall.type = metadata.type;
}
orderedCalls.push(orderedCall);

That would cut down on the noise in the tests, among other things. If it's important to have type: null then, carry on!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this already is marked as an optional field.

@papigers I apologize for the back and forth on this. Since this is already an optional field, how about reverting the addition of all the type: nulls to focus this PR on just the logic & results that actually change?

@ghost ghost added the CLA Signed label Jul 12, 2016
@@ -23,9 +23,14 @@ import type {Variables} from 'RelayTypes';

const invariant = require('invariant');

type Metadata = {
type: ?string,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's make this type?: ?string

@ghost ghost added the CLA Signed label Aug 4, 2016
@josephsavona
Copy link
Contributor

@papigers Thanks again for this PR. I commented to request some changes. Also, scanning through i don't see any tests that actually end up with type having a non-null value, which means it doesn't look like we're really testing the change itself.

I apologize if I missed something, but if not can you add a test that has a non-null type? This would be an enum or object argument.

@psalz
Copy link
Contributor

psalz commented Aug 12, 2016

I just ran into the same issue - any updates on this?

@josephsavona
Copy link
Contributor

@papigers are you able to update the PR?

@ghost ghost added the CLA Signed label Aug 12, 2016
@papigers
Copy link
Author

Not any time soon , I'm afraid. Too busy..

@josephsavona
Copy link
Contributor

closing in favor of #1336 - thanks @papigers!

facebook-github-bot pushed a commit that referenced this pull request Aug 17, 2016
Summary:
As papigers currently doesn't have time to finish #1257 I decided to take over.
Closes #1336

Differential Revision: D3714846

Pulled By: josephsavona

fbshipit-source-id: 0e4fd7648bc47c0eca9865ed31cec42ff6c3e55a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants