-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: upgrade graphql-go-tools with add directive asyncResolve for ar…
…ray node.
- Loading branch information
xufeixiang
committed
Nov 1, 2024
1 parent
c5cfd42
commit 251b052
Showing
4 changed files
with
44 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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{}) | ||
} |
Submodule wundergraphGitSubmodule
updated
3 files
+1 −1 | go.mod | |
+2 −2 | go.sum | |
+1 −0 | pkg/logging/logging.go |