Skip to content

Commit

Permalink
Merge pull request #1514 from 99designs/bump-gqlparser
Browse files Browse the repository at this point in the history
Bump gqlparser to v2.2.0
  • Loading branch information
lwc authored Apr 14, 2021
2 parents f4bf1f5 + 4e88198 commit bf2fdf4
Show file tree
Hide file tree
Showing 21 changed files with 615 additions and 30 deletions.
4 changes: 2 additions & 2 deletions codegen/testserver/directive.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ directive @toNull on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | FIELD_DEFINI
directive @directive1 on FIELD_DEFINITION
directive @directive2 on FIELD_DEFINITION
directive @unimplemented on FIELD_DEFINITION
directive @order1(location: String!) on FIELD_DEFINITION | OBJECT
directive @order1(location: String!) repeatable on FIELD_DEFINITION | OBJECT
directive @order2(location: String!) on OBJECT

extend type Query {
Expand Down Expand Up @@ -42,7 +42,7 @@ input InnerDirectives {
message: String! @length(min: 1, message: "not valid")
}

type ObjectDirectives @order1(location: "ObjectDirectives_object_1") @order2(location: "ObjectDirectives_object_2") {
type ObjectDirectives @order1(location: "order1_1") @order1(location: "order1_2") @order2(location: "order2_1") {
text: String! @length(min: 0, max: 7, message: "not valid")
nullableText: String @toNull
order: [String!]!
Expand Down
5 changes: 3 additions & 2 deletions codegen/testserver/directive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,9 @@ func TestDirectives(t *testing.T) {
require.Equal(t, "Ok", resp.DirectiveObject.Text)
require.True(t, resp.DirectiveObject.NullableText == nil)
require.Equal(t, "Query_field", resp.DirectiveObject.Order[0])
require.Equal(t, "ObjectDirectives_object_2", resp.DirectiveObject.Order[1])
require.Equal(t, "ObjectDirectives_object_1", resp.DirectiveObject.Order[2])
require.Equal(t, "order2_1", resp.DirectiveObject.Order[1])
require.Equal(t, "order1_2", resp.DirectiveObject.Order[2])
require.Equal(t, "order1_1", resp.DirectiveObject.Order[3])
})
t.Run("when directive returns nil & custom go field is not nilable", func(t *testing.T) {
var resp struct {
Expand Down
63 changes: 55 additions & 8 deletions codegen/testserver/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions codegen/testserver/input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,24 @@ func TestInput(t *testing.T) {
require.NoError(t, err)
require.False(t, resp.InputNullableSlice)
})

t.Run("coerce single value to slice", func(t *testing.T) {
check := func(ctx context.Context, arg []string) (b bool, e error) {
return len(arg) == 1 && arg[0] == "coerced", nil
}
resolvers.QueryResolver.InputSlice = check
resolvers.QueryResolver.InputNullableSlice = check

var resp struct {
Coerced bool
}
var err error
err = c.Post(`query { coerced: inputSlice(arg: "coerced") }`, &resp)
require.NoError(t, err)
require.True(t, resp.Coerced)

err = c.Post(`query { coerced: inputNullableSlice(arg: "coerced") }`, &resp)
require.NoError(t, err)
require.True(t, resp.Coerced)
})
}
40 changes: 40 additions & 0 deletions example/chat/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions example/config/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions example/dataloader/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions example/federation/accounts/graph/generated/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bf2fdf4

Please sign in to comment.