Add "generic" option to the "optional" configuration for handling nullable types (#252)

This is an implementation for #251, it adds a new `"generic"` option for
the `"optional"` configuration, and a companion type
`"optional_generic_type"` which is a fully qualified type with a
placeholder `%` for the generic parameter.

Co-authored-by: Dylan R. Johnston <[email protected]>
Co-authored-by: Ben Kraft <[email protected]>
This commit is contained in:
Dylan R. Johnston
2023-05-06 10:40:03 -07:00
committed by GitHub
co-authored by Dylan R. Johnston Ben Kraft
parent 94b6a71403
commit c61d7acaa5
8 changed files with 279 additions and 12 deletions
+5
View File
@@ -214,6 +214,11 @@ func TestGenerateWithConfig(t *testing.T) {
Generated: "generated.go",
Optional: "pointer",
}},
{"OptionalGeneric", "", []string{"ListInput.graphql", "QueryWithSlices.graphql"}, &Config{
Generated: "generated.go",
Optional: "generic",
OptionalGenericType: "github.com/Khan/genqlient/internal/testutil.Option",
}},
}
sourceFilename := "SimpleQuery.graphql"