-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add graphman create/remove commands to graphql api #5685
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
Merged
shiyasmohd
merged 5 commits into
master
from
shiyasmohd/add-graphman-create-remove-to-graphql-api
Nov 8, 2024
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6f6c0fa
graphman: add graphman create command to graphql api
shiyasmohd d79d8d1
graphman: add graphman remove command to graphql api
shiyasmohd 01067bc
refactor: change ordering of imports
shiyasmohd 8cc6c17
graphman: add tests for graphman create graphql api
shiyasmohd b772320
graphman: add tests for graphman remove graphql api
shiyasmohd 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
25 changes: 25 additions & 0 deletions
25
server/graphman/src/resolvers/deployment_mutation/create.rs
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,25 @@ | ||
| use crate::resolvers::context::GraphmanContext; | ||
| use anyhow::anyhow; | ||
| use async_graphql::Result; | ||
| use graph::prelude::SubgraphName; | ||
| use graph_store_postgres::command_support::catalog; | ||
| use graphman::GraphmanError; | ||
|
|
||
| pub fn run(ctx: &GraphmanContext, name: &String) -> Result<()> { | ||
| let primary_pool = ctx.primary_pool.get().map_err(GraphmanError::from)?; | ||
| let mut catalog_conn = catalog::Connection::new(primary_pool); | ||
|
|
||
| let name = match SubgraphName::new(name) { | ||
| Ok(name) => name, | ||
| Err(_) => { | ||
| return Err(GraphmanError::Store(anyhow!( | ||
| "Subgraph name must contain only a-z, A-Z, 0-9, '-' and '_'" | ||
| )) | ||
| .try_into()?) | ||
isum marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| }; | ||
|
|
||
| catalog_conn.create_subgraph(&name)?; | ||
|
|
||
| Ok(()) | ||
| } | ||
26 changes: 26 additions & 0 deletions
26
server/graphman/src/resolvers/deployment_mutation/remove.rs
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,26 @@ | ||
| use crate::resolvers::context::GraphmanContext; | ||
isum marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| use anyhow::anyhow; | ||
| use async_graphql::Result; | ||
| use graph::prelude::{StoreEvent, SubgraphName}; | ||
| use graph_store_postgres::command_support::catalog; | ||
| use graphman::GraphmanError; | ||
|
|
||
| pub fn run(ctx: &GraphmanContext, name: &String) -> Result<()> { | ||
| let primary_pool = ctx.primary_pool.get().map_err(GraphmanError::from)?; | ||
| let mut catalog_conn = catalog::Connection::new(primary_pool); | ||
|
|
||
| let name = match SubgraphName::new(name) { | ||
| Ok(name) => name, | ||
| Err(_) => { | ||
| return Err(GraphmanError::Store(anyhow!( | ||
| "Subgraph name must contain only a-z, A-Z, 0-9, '-' and '_'" | ||
| )) | ||
| .try_into()?) | ||
isum marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| }; | ||
|
|
||
| let changes = catalog_conn.remove_subgraph(name)?; | ||
| catalog_conn.send_store_event(&ctx.notification_sender, &StoreEvent::new(changes))?; | ||
|
|
||
| Ok(()) | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.