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

Fix issue with Relay serialization #2638

Closed
wants to merge 6 commits into from

Conversation

freiksenet
Copy link
Contributor

Fixes #2633.

I had to add dependency to actually add enums with proper test values, because monolithic SDL-first is so limited.

@freiksenet
Copy link
Contributor Author

For some reason it's not picking up a dependency.

@nodkz
Copy link
Contributor

nodkz commented Feb 5, 2019

@freiksenet i'll drop a line here when directives sdl support will be added to graphql-compose

ETA today or tomorrow

@nodkz
Copy link
Contributor

nodkz commented Feb 5, 2019

Done graphql-compose@5.8.1 fixes parsimg and schema construction from SDL with directives in schemaComposer.addTypeDefs(sdl: string) method

);
function buildSchema() {
// Compose upstream is going to add AST directives soon, making this simpler
const composer = new SchemaComposer();
Copy link
Contributor

Choose a reason for hiding this comment

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

graphql-js supports extending schemas, can we just use that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you point me to that? extendSchema only support extending via AST.

__typename_mutated
}
friends_mutated(after_mutated: $after_mutated, first_mutated: $first_mutated, traits_mutated: [HELPFUL_mutated]) {
friends_mutated(after_mutated: $after_mutated, first_mutated: $first_mutated, traits_mutated: [DERISIVE]) {
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 keep the original N/N_mutated style just to make it more obvious what the test is doing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't, serialization for enums only returns valid values and HEPLFUL_mutated isn't a valid enum value for traits.

type.name,
value,
);
return value;
return result;
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't remember if GraphQLInputObject and GraphQLList also support serialize(), if they do can we just use the approach here for all types (ie replace the body of printLiteral w the body of the enum case)? Even if lists/objects don't work, we could do this for all enums and scalars.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only scalars and enums have serialize.

@@ -13,6 +13,7 @@
"dependencies": {
"@babel/runtime": "^7.0.0",
"fbjs": "^1.0.0",
"graphql-compose": "^5.8.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Same question, we should use the built-in mechanism to extend schemas.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's my "lodash" for GraphQL type system 😈

If not today then it will be used tomorrow. Just give me some time to make this lib popular and right solution for such kind of problems.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Which mechanism? extendSchema only supports extending through AST.

@freiksenet
Copy link
Contributor Author

It's pretty critical for us to get this merged and released, because 2.0.0 is breaking for us (Gatsby). If you can't merge additional libraries for test, then I think this should be merged without new tests.

@KyleAMathews
Copy link
Contributor

Appreciate y'alls help getting this merged!

@josephsavona
Copy link
Contributor

extendSchema only supports extending through AST.

Right - what I'm wondering is if we can start with a very minimal schema defined in code, and then extend it with an AST schema derived from the testschema.graphql file. I'm concerned about adding third-party dependencies to something as critical as our core test suite (which could affect both test performance and reliability).

If that doesn't work, let's split this into two steps as you suggested: first we can land the printer changes to use serialize(), then explore a follow-up PR to add regression tests that unions w custom values work.

@freiksenet
Copy link
Contributor Author

Right - what I'm wondering is if we can start with a very minimal schema defined in code, and then extend it with an AST schema derived from the testschema.graphql file. I'm concerned about adding third-party dependencies to something as critical as our core test suite (which could affect both test performance and reliability).

Right, I didn't think about doing it in other direction. I'll try to do it tomorrow.

@freiksenet
Copy link
Contributor Author

OK, I had to do double extend for this to work, because there seems to be a bug in AST Builder that sometimes makes it not use the defined type map function, probably when it's input types or maybe argument types.

@freiksenet
Copy link
Contributor Author

Any update on this?

@freiksenet freiksenet closed this Feb 12, 2019
@freiksenet freiksenet reopened this Feb 12, 2019
@freiksenet
Copy link
Contributor Author

Disregard the closure, I misclicked when commenting.

@freiksenet
Copy link
Contributor Author

Pushed additional test for another regression we found that is fixed by this.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@josephsavona has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@josephsavona
Copy link
Contributor

josephsavona commented Feb 14, 2019

I manually updated the imported version to account for the latest changes - note that I had to make some changes for backwards compatibility purposes for internal code, so updates on this PR won't apply cleanly to the imported version. Do you foresee any more changes?

edit: I'm landing this, so too late for changes!

@josephsavona
Copy link
Contributor

Thanks for letting us know about this and sending a fix!

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.

None yet

6 participants