Skip to content

Commit

Permalink
feat: upgrade graphql-go-tools with add directive asyncResolve for ar…
Browse files Browse the repository at this point in the history
…ray node.
  • Loading branch information
xufeixiang committed Nov 1, 2024
1 parent c5cfd42 commit 251b052
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 5 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/getkin/kin-openapi v0.120.0
github.com/ghodss/yaml v1.0.0
github.com/go-openapi/jsonpointer v0.19.6
github.com/goccy/go-json v0.10.2
github.com/google/uuid v1.3.0
github.com/gorilla/websocket v1.5.0
github.com/invopop/jsonschema v0.7.0
Expand Down Expand Up @@ -65,7 +66,6 @@ require (
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-redis/cache/v8 v8.4.1 // indirect
github.com/go-redis/redis/v8 v8.11.5 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang-jwt/jwt/v4 v4.4.2 // indirect
Expand Down Expand Up @@ -168,6 +168,6 @@ replace (
github.com/flowchartsman/handlebars/v3 => github.com/fireboomio/handlebars/v3 v3.0.0-20230407011829-1693185f0572
github.com/getkin/kin-openapi => github.com/fireboomio/kin-openapi v0.0.0-20240110095352-e1b4433e41a8
github.com/prisma/prisma-client-go => github.com/fireboomio/prisma-client-go v0.0.0-20240614073744-961bb930abe4
github.com/wundergraph/graphql-go-tools => github.com/fireboomio/graphql-go-tools v0.0.0-20240906084833-9d754bc747d6
github.com/wundergraph/graphql-go-tools => github.com/fireboomio/graphql-go-tools v0.0.0-20241101081953-5de6406c15e8
github.com/wundergraph/wundergraph => ./wundergraphGitSubmodule
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
github.com/fireboomio/graphql-go-tools v0.0.0-20240906084833-9d754bc747d6 h1:iKfU4DWaY7t2V3rM3gqkkgdLdZCeXWYLPIxfkpc5KTg=
github.com/fireboomio/graphql-go-tools v0.0.0-20240906084833-9d754bc747d6/go.mod h1:8Lj3WnDT5m+QGamBlqAqwn++OVcL30FXG+o6kf810bc=
github.com/fireboomio/graphql-go-tools v0.0.0-20241101081953-5de6406c15e8 h1:I7vFAEPdwl9USq5KvSwosrilSjLS9BG36InZdHOqU/I=
github.com/fireboomio/graphql-go-tools v0.0.0-20241101081953-5de6406c15e8/go.mod h1:8Lj3WnDT5m+QGamBlqAqwn++OVcL30FXG+o6kf810bc=
github.com/fireboomio/handlebars/v3 v3.0.0-20230407011829-1693185f0572 h1:utP3HLcMr38qlFFzMwjQeUWM0jxg+MPgktKucOQ2t4I=
github.com/fireboomio/handlebars/v3 v3.0.0-20230407011829-1693185f0572/go.mod h1:zdeQ3Qna7Bd2JQiobPXuZKDOG3j7Byo6uXDaMLXHVAw=
github.com/fireboomio/kin-openapi v0.0.0-20240110095352-e1b4433e41a8 h1:KaancvImcVJEnUVUxDwugkP6F7Yvb2FgasDuVkknZeU=
Expand Down
39 changes: 39 additions & 0 deletions pkg/engine/directives/selection_asyncresolve.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Package directives
/*
实现VariableDirective接口,只能定义在LocationVariableDefinition上
Resolve 标识参数内部传递,与@export组合使用
*/
package directives

import (
"fmt"
"github.com/getkin/kin-openapi/openapi3"
"github.com/vektah/gqlparser/v2/ast"
)

const asyncResolveName = "asyncResolve"

type asyncResolve struct{}

func (s *asyncResolve) Directive() *ast.DirectiveDefinition {
return &ast.DirectiveDefinition{
Name: asyncResolveName,
Locations: []ast.DirectiveLocation{ast.LocationField},
}
}

func (s *asyncResolve) Definitions() ast.DefinitionList {
return nil
}

func (s *asyncResolve) Resolve(resolver *SelectionResolver) (err error) {
if resolver.Schema.Value.Type != openapi3.TypeArray {
err = fmt.Errorf("@%s directive only support on array type", asyncResolveName)
return
}
return
}

func init() {
registerDirective(asyncResolveName, &asyncResolve{})
}
2 changes: 1 addition & 1 deletion wundergraphGitSubmodule

0 comments on commit 251b052

Please sign in to comment.