-
Notifications
You must be signed in to change notification settings - Fork 125
Add schema proposal composition background job #7706
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
Open
jdolle
wants to merge
31
commits into
main
Choose a base branch
from
composition-job
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,612
−341
Open
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
667a15a
Add schema proposal composition background job
jdolle 88f515f
Add pubsub, subscrition, and composition state for proposals
jdolle e259a34
revert log change
jdolle 0eb9cdd
note
jdolle ffeef08
Remove unused function
jdolle 49d1a2c
Remove log
jdolle 406062c
Add limits to patch fetching; check targetId
jdolle d841a41
Linting errors
jdolle 2e274ba
Merge branch 'main' into composition-job
jdolle f8cafbb
Add composition reason; fix timestamp format
jdolle e42665b
Remove @hive/api from workflows' dependencies
jdolle 6b65344
Fix type import
jdolle b2185a3
Update lockfile
jdolle 2c42fd9
Fix generated type
jdolle 9f008c1
Fix workflows deployment
jdolle 699a373
Fix community & env name
jdolle 0dc136e
Basic composition ui; fix names
jdolle 1aa49aa
add key
jdolle 4d00a88
Unify redis logger utilities
jdolle 887918c
Fix packages
jdolle e26cf7f
Later version of graphile worker
jdolle 1c974ed
Use nullable instead of optional
jdolle 5d954d7
Remove proposal version select
jdolle 201f156
Pass in external composition state
jdolle 8544455
Fix proposal manager permissions; fix workflow redis env var; add an …
jdolle 6e8a950
Add subscription test and more
jdolle 8e4142c
Lint
jdolle 57b33f2
Merge remote-tracking branch 'origin/main' into composition-job
jdolle 24055c3
service heading style tweak
jdolle 016527f
Rename submodule to avoid conflict with actual package
jdolle 748f7e4
Check integrity
jdolle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| import { graphql } from 'testkit/gql'; | ||
| import { ProjectType, ResourceAssignmentModeType } from 'testkit/gql/graphql'; | ||
| import { execute } from 'testkit/graphql'; | ||
| import { initSeed } from 'testkit/seed'; | ||
|
|
||
| const CreateProposalMutation = graphql(` | ||
| mutation CreateProposalMutation($input: CreateSchemaProposalInput!) { | ||
| createSchemaProposal(input: $input) { | ||
| ok { | ||
| schemaProposal { | ||
| id | ||
| } | ||
| } | ||
| error { | ||
| message | ||
| } | ||
| } | ||
| } | ||
| `); | ||
|
|
||
| describe('Schema Proposals', () => { | ||
| test.concurrent( | ||
| 'cannot be proposed without "schemaProposal:modify" permission', | ||
| async ({ expect }) => { | ||
| const { createOrg, ownerToken } = await initSeed().createOwner(); | ||
| const { createProject, createOrganizationAccessToken, setFeatureFlag } = await createOrg(); | ||
| await setFeatureFlag('schemaProposals', true); | ||
| const { target } = await createProject(ProjectType.Federation); | ||
| const { privateAccessKey: accessKey } = await createOrganizationAccessToken( | ||
| { | ||
| resources: { | ||
| mode: ResourceAssignmentModeType.All, | ||
| }, | ||
| permissions: ['schemaProposal:describe'], | ||
| }, | ||
| ownerToken, | ||
| ); | ||
|
|
||
| const result = await execute({ | ||
| document: CreateProposalMutation, | ||
| variables: { | ||
| input: { | ||
| target: { byId: target.id }, | ||
| author: 'Jeff', | ||
| title: 'Proposed changes to the schema...', | ||
| }, | ||
| }, | ||
| authToken: accessKey, | ||
| }).then(r => r.expectGraphQLErrors()); | ||
| }, | ||
| ); | ||
|
|
||
| test.concurrent( | ||
| 'can be proposed successfully with "schemaProposal:modify" permission', | ||
| async ({ expect }) => { | ||
| const { createOrg, ownerToken } = await initSeed().createOwner(); | ||
| const { createProject, createOrganizationAccessToken, setFeatureFlag } = await createOrg(); | ||
| await setFeatureFlag('schemaProposals', true); | ||
| const { target } = await createProject(ProjectType.Federation); | ||
|
|
||
| const { privateAccessKey: accessKey } = await createOrganizationAccessToken({ | ||
| resources: { | ||
| mode: ResourceAssignmentModeType.All, | ||
| }, | ||
| permissions: ['schemaProposal:modify'], | ||
| }); | ||
|
|
||
| const result = await execute({ | ||
| document: CreateProposalMutation, | ||
| variables: { | ||
| input: { | ||
| target: { byId: target.id }, | ||
| author: 'Jeff', | ||
| title: 'Proposed changes to the schema...', | ||
| }, | ||
| }, | ||
| authToken: accessKey, | ||
| }).then(r => r.expectNoGraphQLErrors()); | ||
|
|
||
| expect(result.createSchemaProposal.ok?.schemaProposal).toHaveProperty('id'); | ||
| }, | ||
| ); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| import { graphql } from 'testkit/gql'; | ||
| import { ProjectType, ResourceAssignmentModeType } from 'testkit/gql/graphql'; | ||
| import { execute } from 'testkit/graphql'; | ||
| import { initSeed } from 'testkit/seed'; | ||
|
|
||
| const CreateProposalMutation = graphql(` | ||
| mutation CreateProposalMutation($input: CreateSchemaProposalInput!) { | ||
| createSchemaProposal(input: $input) { | ||
| ok { | ||
| schemaProposal { | ||
| id | ||
| } | ||
| } | ||
| error { | ||
| message | ||
| } | ||
| } | ||
| } | ||
| `); | ||
|
|
||
| const ReadProposalQuery = graphql(` | ||
| query ReadProposalQuery($input: SchemaProposalInput!) { | ||
| schemaProposal(input: $input) { | ||
| title | ||
| description | ||
| checks(input: { latestPerService: true }) { | ||
| edges { | ||
| node { | ||
| id | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| `); | ||
|
|
||
| /** | ||
| * Creates a proposal and returns a token with specified permissions | ||
| **/ | ||
| async function setup(input: { | ||
| tokenPermissions: string[]; | ||
| }): Promise<{ accessKey: string; proposalId: string }> { | ||
| const { createOrg, ownerToken } = await initSeed().createOwner(); | ||
| const { createProject, createOrganizationAccessToken, setFeatureFlag } = await createOrg(); | ||
| await setFeatureFlag('schemaProposals', true); | ||
| const { target } = await createProject(ProjectType.Federation); | ||
|
|
||
| // create as owner | ||
| const result = await execute({ | ||
| document: CreateProposalMutation, | ||
| variables: { | ||
| input: { | ||
| target: { byId: target.id }, | ||
| author: 'Jeff', | ||
| title: 'Proposed changes to the schema...', | ||
| }, | ||
| }, | ||
| token: ownerToken, | ||
| }).then(r => r.expectNoGraphQLErrors()); | ||
|
|
||
| const { privateAccessKey: accessKey } = await createOrganizationAccessToken( | ||
| { | ||
| resources: { | ||
| mode: ResourceAssignmentModeType.All, | ||
| }, | ||
| permissions: input.tokenPermissions, | ||
| }, | ||
| ownerToken, | ||
| ); | ||
| const proposalId = result.createSchemaProposal.ok?.schemaProposal.id!; | ||
| return { accessKey, proposalId }; | ||
| } | ||
|
|
||
| describe('Schema Proposals', () => { | ||
| test.concurrent( | ||
| 'can read proposal with "schemaProposal:describe" permission', | ||
| async ({ expect }) => { | ||
| const { accessKey, proposalId } = await setup({ | ||
| tokenPermissions: ['schemaProposal:describe'], | ||
| }); | ||
|
|
||
| { | ||
| const proposal = await execute({ | ||
| document: ReadProposalQuery, | ||
| variables: { | ||
| input: { | ||
| id: proposalId, | ||
| }, | ||
| }, | ||
| token: accessKey, | ||
| }).then(r => r.expectNoGraphQLErrors()); | ||
|
|
||
| expect(proposal.schemaProposal?.title).toMatchInlineSnapshot( | ||
| `Proposed changes to the schema...`, | ||
| ); | ||
| } | ||
| }, | ||
| ); | ||
|
|
||
| test.concurrent('cannot read proposal without "schemaProposal:describe" permission', async () => { | ||
| const { accessKey, proposalId } = await setup({ tokenPermissions: [] }); | ||
|
|
||
| { | ||
| await execute({ | ||
| document: ReadProposalQuery, | ||
| variables: { | ||
| input: { | ||
| id: proposalId, | ||
| }, | ||
| }, | ||
| token: accessKey, | ||
| }).then(r => r.expectGraphQLErrors()); | ||
| } | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved after the schema instance because i need to reference it.