Skip to content

Commit b2fd449

Browse files
committed
fix: use nullableID for filter_id to support unsetting
Sends GraphQL null instead of an empty string when filter_id is removed from config. Aligns with how all check resources handle nullable filter IDs. Made-with: Cursor
1 parent dabc6ee commit b2fd449

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

opslevel/resource_opslevel_campaign.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,9 @@ func (r *CampaignResource) Create(ctx context.Context, req resource.CreateReques
156156
}
157157

158158
input := opslevel.CampaignCreateInput{
159-
Name: planModel.Name.ValueString(),
160-
OwnerId: opslevel.ID(planModel.OwnerId.ValueString()),
161-
}
162-
if !planModel.FilterId.IsNull() {
163-
input.FilterId = opslevel.RefOf(opslevel.ID(planModel.FilterId.ValueString()))
159+
Name: planModel.Name.ValueString(),
160+
OwnerId: opslevel.ID(planModel.OwnerId.ValueString()),
161+
FilterId: nullableID(planModel.FilterId.ValueStringPointer()),
164162
}
165163
if !planModel.ProjectBrief.IsNull() {
166164
brief := planModel.ProjectBrief.ValueString()
@@ -262,11 +260,7 @@ func (r *CampaignResource) Update(ctx context.Context, req resource.UpdateReques
262260

263261
updateInput.OwnerId = opslevel.RefOf(opslevel.ID(planModel.OwnerId.ValueString()))
264262

265-
if !planModel.FilterId.IsNull() {
266-
updateInput.FilterId = opslevel.RefOf(opslevel.ID(planModel.FilterId.ValueString()))
267-
} else if !stateModel.FilterId.IsNull() {
268-
updateInput.FilterId = opslevel.RefOf(opslevel.ID(""))
269-
}
263+
updateInput.FilterId = nullableID(planModel.FilterId.ValueStringPointer())
270264

271265
if !planModel.ProjectBrief.IsNull() {
272266
brief := planModel.ProjectBrief.ValueString()

0 commit comments

Comments
 (0)