-
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 to add support directive @skipVariable…
…, and make selection field print full hash.
- Loading branch information
xufeixiang
committed
Jul 8, 2024
1 parent
5c3c4a8
commit 901ed6f
Showing
8 changed files
with
107 additions
and
37 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
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,46 @@ | ||
// Package directives | ||
/* | ||
实现VariableDirective接口,只能定义在LocationVariableDefinition上 | ||
Resolve 标识参数内部传递,与@export组合使用 | ||
*/ | ||
package directives | ||
|
||
import ( | ||
"fireboom-server/pkg/common/consts" | ||
"fireboom-server/pkg/plugins/i18n" | ||
"github.com/vektah/gqlparser/v2/ast" | ||
) | ||
|
||
const ( | ||
skipVariableName = "skipVariable" | ||
skipVariableArgName = "variables" | ||
) | ||
|
||
type skipVariable struct{} | ||
|
||
func (s *skipVariable) Directive() *ast.DirectiveDefinition { | ||
return &ast.DirectiveDefinition{ | ||
Description: prependMockAllowed(appendIfExistExampleGraphql(i18n.SkipVariableDesc.String())), | ||
Name: skipVariableName, | ||
Locations: []ast.DirectiveLocation{ast.LocationField}, | ||
Arguments: ast.ArgumentDefinitionList{{ | ||
Name: skipVariableArgName, | ||
Type: ast.NonNullListType(&ast.Type{NamedType: consts.ScalarString}, nil), | ||
}, { | ||
Name: argIfRuleName, | ||
Type: ast.NonNullNamedType(consts.ScalarString, nil), | ||
}}, | ||
} | ||
} | ||
|
||
func (s *skipVariable) Definitions() ast.DefinitionList { | ||
return nil | ||
} | ||
|
||
func (s *skipVariable) Resolve(resolver *SelectionResolver) (err error) { | ||
return includeDirective.Resolve(resolver) | ||
} | ||
|
||
func init() { | ||
registerDirective(skipVariableName, &skipVariable{}) | ||
} |
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 @@ | ||
SkipVariableDesc = "作用于标量选择集上,根据条件跳过参数填充" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.