Skip to content

Commit

Permalink
fix: allow TF resource to be created based on existing subgraph
Browse files Browse the repository at this point in the history
  • Loading branch information
BramKaashoek committed May 15, 2023
1 parent d45092c commit 25c3bf3
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions internal/provider/sub_graph_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,6 @@ func (r *SubGraphResource) Create(ctx context.Context, req resource.CreateReques
return
}

if graph.Name != "" {
resp.Diagnostics.AddError(
"Sub Graph already exists",
fmt.Sprintf(
"Sub Graph `%s` already exits, if you want to submit pre-existing graph, "+
"please import the resource",
name,
),
)
return
}

result, err := r.client.SubmitSubGraph(
ctx, &apollostudio.SubmitOptions{
SubGraphSchema: []byte(s),
Expand All @@ -170,7 +158,10 @@ func (r *SubGraphResource) Create(ctx context.Context, req resource.CreateReques
if !result.WasCreated && graph.Name != "" {
resp.Diagnostics.AddWarning(
"No new subgraph was created",
"New sub graph was not created, submitted only",
fmt.Sprintf(
"Sub Graph `%s` already exits, did not create new sub graph",
name,
),
)
}

Expand Down

0 comments on commit 25c3bf3

Please sign in to comment.