terraform-provider-graphql icon indicating copy to clipboard operation
terraform-provider-graphql copied to clipboard

Support non-string computed keys

Open dlecocq opened this issue 11 months ago • 2 comments

Dealing with an API with return values that are non-string scalars, and I need to be able to consume them as part of this provider. Specifically, an API with an id that is getting returned as a number, which is causing this trace:

goroutine 14 [running]:
github.com/sullivtr/terraform-provider-graphql/graphql.computeMutationVariableKeys(0xc0001c4200, 0x1762dcf)
	github.com/sullivtr/terraform-provider-graphql/graphql/keys.go:36 +0x18a
github.com/sullivtr/terraform-provider-graphql/graphql.computeMutationVariables({0xc0001c4200, 0x31, 0x200}, 0x1663040)
	github.com/sullivtr/terraform-provider-graphql/graphql/resource_graphql_mutation.go:327 +0x186
github.com/sullivtr/terraform-provider-graphql/graphql.executeCreateHook({0x184c568, 0xc000054ea0}, 0x0, {0x16473e0, 0xc00009ff60})
	github.com/sullivtr/terraform-provider-graphql/graphql/resource_graphql_mutation.go:273 +0x29f
github.com/sullivtr/terraform-provider-graphql/graphql.resourceGraphqlMutationCreate({0x184c568, 0xc000054ea0}, 0xc0005597b8, {0x16473e0, 0xc00009ff60})
	github.com/sullivtr/terraform-provider-graphql/graphql/resource_graphql_mutation.go:128 +0x45
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0xc0000b8380, {0x184c4f8, 0xc0002842c0}, 0x2, {0x16473e0, 0xc00009ff60})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:330 +0x12e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0000b8380, {0x184c4f8, 0xc0002842c0}, 0xc0003362a0, 0xc00009e700, {0x16473e0, 0xc00009ff60})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:456 +0x871
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc0000a6780, {0x184c4f8, 0xc0002842c0}, 0xc000312500)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:955 +0x9aa
github.com/hashicorp/terraform-plugin-go/tfprotov5/server.(*server).ApplyResourceChange(0xc00009efc0, {0x184c5a0, 0xc0004a6270}, 0x101732b)
	github.com/hashicorp/[email protected]/tfprotov5/server/server.go:332 +0x6c
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x1729e00, 0xc00009efc0}, {0x184c5a0, 0xc0004a6270}, 0xc000054660, 0x0)
	github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:380 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000ce700, {0x1858df0, 0xc00019c480}, 0xc0000b2300, 0xc0004226c0, 0x1ce1c60, 0x0)
	google.golang.org/[email protected]/server.go:1194 +0xc8f
google.golang.org/grpc.(*Server).handleStream(0xc0000ce700, {0x1858df0, 0xc00019c480}, 0xc0000b2300, 0x0)
	google.golang.org/[email protected]/server.go:1517 +0xa2a
google.golang.org/grpc.(*Server).serveStreams.func1.2()
	google.golang.org/[email protected]/server.go:859 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
	google.golang.org/[email protected]/server.go:857 +0x294

Error: The terraform-provider-graphql_2.5.4 plugin crashed!

dlecocq avatar Mar 15 '24 21:03 dlecocq

I'm trying to run the tests locally, but the makefile isn't working for me (yet). In the meantime, I'm pushing this MR hoping that either 1) automated tests kick off or 2) it's quick enough for someone with a working environment to run the tests to verify.

dlecocq avatar Mar 15 '24 21:03 dlecocq

Ah, was able to get the tests working well enough locally to demonstrate that the tests fail without the fix commit, and pass with it.

dlecocq avatar Mar 15 '24 22:03 dlecocq

Hey, i hitting an issue where a nested mutation_variables makes some issue. Is this fix solving such a issue?

elixxx avatar Aug 16 '24 10:08 elixxx

Thank you, @dlecocq. I have not have any capacity to maintain this provider the past year or so so I appreciate the contribution. This should help a lot.

sullivtr avatar Sep 02 '24 19:09 sullivtr

@dlecocq This will be tagged as v2.5.5 which is being released right now. It should be available soon.

sullivtr avatar Sep 02 '24 19:09 sullivtr