Skip to content

Commit

Permalink
Issue 3202
Browse files Browse the repository at this point in the history
  • Loading branch information
krupyansky committed Jul 30, 2024
1 parent 783685c commit cf297ef
Show file tree
Hide file tree
Showing 14 changed files with 300 additions and 82 deletions.
88 changes: 84 additions & 4 deletions codegen/testserver/followschema/directive.generated.go

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

8 changes: 6 additions & 2 deletions codegen/testserver/followschema/directive.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extend type Query {
directiveField: String
directiveDouble: String @directive1 @directive2
directiveUnimplemented: String @unimplemented
directiveConcurrent: [ObjectDirectivesWithCustomGoModel!]!
directiveConcurrent: [ObjectDirectivesConcurrent!]!
}

extend type Subscription {
Expand Down Expand Up @@ -51,6 +51,10 @@ type ObjectDirectives @order1(location: "order1_1") @order1(location: "order1_2"
order: [String!]!
}

type ObjectDirectivesWithCustomGoModel @concurrent {
type ObjectDirectivesWithCustomGoModel {
nullableText: String @toNull
}

type ObjectDirectivesConcurrent @concurrent {
key: Int!
}
33 changes: 33 additions & 0 deletions codegen/testserver/followschema/directive_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package followschema

import (
"cmp"
"context"
"errors"
"fmt"
"slices"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -67,6 +69,17 @@ func TestDirectives(t *testing.T) {
return &ok, nil
}

resolvers.QueryResolver.DirectiveConcurrent = func(ctx context.Context) ([]*ObjectDirectivesConcurrent, error) {
return []*ObjectDirectivesConcurrent{
{
Key: 1,
},
{
Key: 2,
},
}, nil
}

okchan := func() (<-chan *string, error) {
res := make(chan *string, 1)
res <- &ok
Expand Down Expand Up @@ -412,6 +425,26 @@ func TestDirectives(t *testing.T) {
require.Nil(t, resp.DirectiveObjectWithCustomGoModel.NullableText)
})
})
t.Run("concurrent directive", func(t *testing.T) {
var resp struct {
DirectiveConcurrent []struct {
Key int
}
}

err := c.Post(`query { directiveConcurrent{ key } }`, &resp)
slices.SortFunc(resp.DirectiveConcurrent, func(a, b struct{ Key int }) int {
return cmp.Compare(a.Key, b.Key)
})

keys := make([]int, 0, len(resp.DirectiveConcurrent))
for _, dc := range resp.DirectiveConcurrent {
keys = append(keys, dc.Key)
}

require.NoError(t, err)
require.Equal(t, []int{1, 2}, keys)
})

t.Run("Subscription directives", func(t *testing.T) {
t.Run("arg directives", func(t *testing.T) {
Expand Down
4 changes: 4 additions & 0 deletions codegen/testserver/followschema/models-gen.go

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

2 changes: 1 addition & 1 deletion codegen/testserver/followschema/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func (r *queryResolver) DirectiveUnimplemented(ctx context.Context) (*string, er
}

// DirectiveConcurrent is the resolver for the directiveConcurrent field.
func (r *queryResolver) DirectiveConcurrent(ctx context.Context) ([]*ObjectDirectivesWithCustomGoModel, error) {
func (r *queryResolver) DirectiveConcurrent(ctx context.Context) ([]*ObjectDirectivesConcurrent, error) {
panic("not implemented")
}

Expand Down
11 changes: 11 additions & 0 deletions codegen/testserver/followschema/root_.generated.go

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

40 changes: 10 additions & 30 deletions codegen/testserver/followschema/schema.generated.go

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

4 changes: 2 additions & 2 deletions codegen/testserver/followschema/stub.go

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

8 changes: 6 additions & 2 deletions codegen/testserver/singlefile/directive.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extend type Query {
directiveField: String
directiveDouble: String @directive1 @directive2
directiveUnimplemented: String @unimplemented
directiveConcurrent: [ObjectDirectivesWithCustomGoModel!]!
directiveConcurrent: [ObjectDirectivesConcurrent!]!
}

extend type Subscription {
Expand Down Expand Up @@ -51,6 +51,10 @@ type ObjectDirectives @order1(location: "order1_1") @order1(location: "order1_2"
order: [String!]!
}

type ObjectDirectivesWithCustomGoModel @concurrent {
type ObjectDirectivesWithCustomGoModel {
nullableText: String @toNull
}

type ObjectDirectivesConcurrent @concurrent {
key: Int!
}
Loading

0 comments on commit cf297ef

Please # to comment.