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(diagnostics): validate up to date hash #301

Merged
merged 7 commits into from
Apr 22, 2024

Conversation

JoviDeCroock
Copy link
Member

During diagnostics when we see a prefix of sha256 we can assume that we generated the hash, this means we can verify whether it's up to date. This adds a warn diagnostic for persisted-operations and warns you when the hash is up to date with the document.

Copy link

changeset-bot bot commented Apr 22, 2024

🦋 Changeset detected

Latest commit: c33a6b0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@0no-co/graphqlsp Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

packages/graphqlsp/src/diagnostics.ts Outdated Show resolved Hide resolved
@@ -247,6 +250,26 @@ export function getGraphQLDiagnostics(
};
}

const hash = callExpression.arguments[0].getText().slice(1, -1);
if (hash.startsWith('sha256:')) {
const upToDateHash = `sha256:${generateHashForDocument(
Copy link
Member

Choose a reason for hiding this comment

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

This may compose into sha256:undefined which then likely always issues the warning instead of bailing out

Copy link
Member Author

Choose a reason for hiding this comment

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

we have basically evaluated all the pre-conditions for this not to happen though

@JoviDeCroock JoviDeCroock merged commit 5865e2a into main Apr 22, 2024
1 check passed
@JoviDeCroock JoviDeCroock deleted the add-validation-for-up-to-date-po branch April 22, 2024 10:50
@github-actions github-actions bot mentioned this pull request Apr 22, 2024
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.

None yet

2 participants