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

feat(graph): allow sharing VCS branches through a lockfile #4899

Merged
merged 7 commits into from
Aug 4, 2022

Conversation

anmonteiro
Copy link
Contributor

🎉 Thanks for submitting a pull request! 🎉

Summary

Fixes #<replace_with_issue_number>


For us to review and ship your PR efficiently, please perform the following steps:

  • Open a bug/issue before writing your code 🧑‍💻. This ensures we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or something that`s on fire 🔥 (e.g. incident related), you can skip this step.
  • Read the contribution guidelines 📖. This ensures your code follows our style guide and
    passes our tests.
  • Update or add tests (if any source code was changed or added) 🧪
  • Update or add documentation (if features were changed or added) 📝
  • Make sure the status checks below are successful ✅

A picture of a cute animal (not mandatory, but encouraged)

@github-actions github-actions bot added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Aug 4, 2022
@github-actions
Copy link

github-actions bot commented Aug 4, 2022

📊 Benchmark results

Comparing with b3dc897

Package size: 230 MB

⬆️ 0.04% increase vs. b3dc897

^                          230 MB  230 MB  230 MB  230 MB  230 MB  230 MB  230 MB  230 MB  230 MB  230 MB 
│  224 MB  224 MB  224 MB   ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐  
│   ┌──┐    ┌──┐    ┌──┐    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
└───┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴──>
    T-12    T-11    T-10    T-9     T-8     T-7     T-6     T-5     T-4     T-3     T-2     T-1      T    
Legend

sgrove
sgrove previously approved these changes Aug 4, 2022
Copy link
Contributor

@sgrove sgrove left a comment

Choose a reason for hiding this comment

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

A few minor changes, but lgtm

* @param {NetlifyGraphLockfile.V0_format} input.lockfile
*/
const writeLockfile = ({ lockfile, siteRoot }) => {
writeFileSync(path.join(siteRoot, NetlifyGraphLockfile.defaultLockFileName), JSON.stringify(lockfile, null, 2))
Copy link
Contributor

Choose a reason for hiding this comment

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

I suspect in the near future we may want a normalizeLockfile function that inserts all the known keys in a deterministic order so that the JSON file is always written out in the same order as well, to prevent spurious changes in 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.

I like that we enforce that invariant in the future. It should hopefully be the case right now if the entrypoint is always NetlifyGraphLockfile.createLockfile

*/
const handleOperationsLibraryPersistedEvent = async (input) => {
const { schemaId, siteRoot } = input
// await updateGraphQLOperationsFileFromPersistedDoc()
Copy link
Contributor

Choose a reason for hiding this comment

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

Delete?


const relevantHasLength = 10
writeGraphQLOperationsSourceFile({ logger, netlifyGraphConfig, operationsDocString })
regenerateFunctionsFileFromOperationsFile({ netlifyGraphConfig, schema })
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we'll need schemaId here

*/
const maybeUpdateSessionFromLockfile = async (input) => {
const { lockfile, netlifyToken, session } = input
const sessionSchemaId = session.metadata && session.metadata.schemaId
Copy link
Contributor

Choose a reason for hiding this comment

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

We should update the underlying query to get session.graphQLSchema.id when it's less painful to do so.

@@ -718,29 +820,80 @@ const generateSessionName = () => {
return sessionName
}

/**
* Mark a session as inactive so it doesn't show up in any UI lists, and potentially becomes available to GC later
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this doctoring correct? And the name would probably be better as idempotentlyUpdateSessionSchemaIdFromLockfile

@anmonteiro anmonteiro requested a review from a team as a code owner August 4, 2022 03:40
@anmonteiro anmonteiro added type: feature code contributing to the implementation of a feature and/or user facing functionality and removed type: feature code contributing to the implementation of a feature and/or user facing functionality labels Aug 4, 2022
@anmonteiro anmonteiro requested a review from sgrove August 4, 2022 05:55
sgrove
sgrove previously approved these changes Aug 4, 2022
@anmonteiro anmonteiro added the automerge Add to Kodiak auto merge queue label Aug 4, 2022
@kodiakhq kodiakhq bot merged commit ad84a46 into main Aug 4, 2022
@kodiakhq kodiakhq bot deleted the anmonteiro/schema-sharing branch August 4, 2022 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Add to Kodiak auto merge queue type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants