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

Refactor the stitching code, update to the latest graphql-tools #1028

Closed
wants to merge 1 commit into from

Conversation

orta
Copy link
Contributor

@orta orta commented May 1, 2018

I'll comment inline

@orta orta force-pushed the stitching_refactor branch from b9e6ea5 to 2b81583 Compare May 1, 2018 21:07
@@ -38,3 +38,4 @@ NODE_ENV=test
PORT=5001
QUERY_DEPTH_LIMIT=10
RESIZING_SERVICE=gemini
REQUEST_TIMEOUT_MS=5000
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we had tests that relied on this

"apollo-link-http": "^1.1.0",
"apollo-link": "1.2.1",
"apollo-link-context": "^1.0.8",
"apollo-link-http": "^1.5.4",
"artsy-morgan": "git://github.com/artsy/artsy-morgan.git",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The specific apollo version is because of ardatan/graphql-tools#765

})
mergedSchema.__allowedLegacyNames = ["__id"]
return mergedSchema
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

👋 single function

},
})
})
})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Our first original merging regression, moved into its own file.

Copy link
Contributor

Choose a reason for hiding this comment

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

dope!

@@ -92,53 +91,3 @@ describe("convection link", () => {
})
})
})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file tests all the HTTP headers in the link now

const newName = remap[name] || name
return newName
}),
])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just a simple rename for the convection types to be the same as what exists inside MP today.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool, makes sense.

},
},
},
})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basically lets each service keep their stitching to themselves. If/when we get to a point where two are trying to stitch resolvers on to the same object, we can deal with it then

@@ -100,7 +100,7 @@ export const SubmissionType = new GraphQLObjectType({
fields: {
...GravityIDFields,
artist_id: {
decription: "The gravity ID for an Artist",
description: "The gravity ID for an Artist",
type: new GraphQLNonNull(GraphQLString),
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 spotted one and figured there might be more

import schema from "schema"
import { mergeSchemas } from "lib/mergeSchemas"
// Please do not add schema imports here while stitching is an ENV flag
//
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The move from static imports to dynamic is so that we can make guarantees about the merged schemas. It won't matter once it's removed from the env var though.


preprocessors: {
"**/*.js": wallaby.compilers.babel(JSON.parse(babelRC)),
"**/*.ts": wallaby.compilers.babel(JSON.parse(babelRC)),
},

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'm the only person using wallaby, so I just keep it up to date for myself

// metaphysics ecosystem.
const remap = {
Submission: "ConsignmentSubmission",
Category: "SubmissionCategoryAggregation",
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious why the Aggregation naming? But 👍 love this!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was the original name in metaphysics, can't remember why it's called that now, but likely was replicating something on convection

convectionSchema,
convectionStitching.extensionSchema,
],
onTypeConflict: (leftType, rightType) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious about this- gravitySchema has Artwork and other conflicting types, so based on this handler now, are we getting errors in development now?

ie- I recall seeing Type Collision Artwork and the like in the existing version. Since we want to keep those from Metaphysics, should we add them to scalarsToKeepInMetaphysics (and rename it to drop 'scalar')?

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 took out merging of gravity's graphql for this as it's not being used, will figure that one out later but we will probably need to either do a full switcheroo with MP's Artist, or rename Grav's GraphQL for the time being.

WRT scalars, those are core primitives that are definitely the same, merging and overwriting we should be handling on a case by case basis

Copy link
Contributor

Choose a reason for hiding this comment

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

Wait, but we are still merging in gravity GraphQL? (or am i misunderstanding the term 'merging' and 'stitching', etc. again 😆 )

Also, there is a mutation we added in Gravity's GraphQL that we wanted to use transparently thru Metaphysics (recordArtworkView).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I'm surprised that removing it didn't break a test then, sure I can get it merged back in with #1032

Copy link
Contributor

Choose a reason for hiding this comment

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

Whoops! I added it in the same style as the Convection ones, there is a mutation in Metaphysics that directly matches the one in Gravity's GraphQL, and which one is used (this was the goal), is behind the ENABLE_SCHEMA_STITCHING flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, that makes sense then yeah! Cool, I'll re-create a version of that test that uses stitching 👍

@orta
Copy link
Contributor Author

orta commented May 2, 2018

Closing in favor of #1032

@orta orta closed this May 2, 2018
@orta orta deleted the stitching_refactor branch May 2, 2018 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants