本文整理汇总了Golang中github.com/housinganywhere/graphql/testutil.RuleError函数的典型用法代码示例。如果您正苦于以下问题:Golang RuleError函数的具体用法?Golang RuleError怎么用?Golang RuleError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RuleError函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestValidate_OverlappingFieldsCanBeMerged_ReportsEachConflictOnce
func TestValidate_OverlappingFieldsCanBeMerged_ReportsEachConflictOnce(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.OverlappingFieldsCanBeMergedRule, `
{
f1 {
...A
...B
}
f2 {
...B
...A
}
f3 {
...A
...B
x: c
}
}
fragment A on Type {
x: a
}
fragment B on Type {
x: b
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`Fields "x" conflict because a and b are different fields.`, 18, 9, 21, 9),
testutil.RuleError(`Fields "x" conflict because a and c are different fields.`, 18, 9, 14, 11),
testutil.RuleError(`Fields "x" conflict because b and c are different fields.`, 21, 9, 14, 11),
})
}
开发者ID:housinganywhere,项目名称:graphql,代码行数:29,代码来源:rules_overlapping_fields_can_be_merged_test.go
示例2: TestValidate_NoUnusedFragments_ContainsUnknownFragmentsWithRefCycle
func TestValidate_NoUnusedFragments_ContainsUnknownFragmentsWithRefCycle(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.NoUnusedFragmentsRule, `
query Foo {
human(id: 4) {
...HumanFields1
}
}
query Bar {
human(id: 4) {
...HumanFields2
}
}
fragment HumanFields1 on Human {
name
...HumanFields3
}
fragment HumanFields2 on Human {
name
}
fragment HumanFields3 on Human {
name
}
fragment Unused1 on Human {
name
...Unused2
}
fragment Unused2 on Human {
name
...Unused1
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`Fragment "Unused1" is never used.`, 22, 7),
testutil.RuleError(`Fragment "Unused2" is never used.`, 26, 7),
})
}
开发者ID:housinganywhere,项目名称:graphql,代码行数:35,代码来源:rules_no_unused_fragments_test.go
示例3: TestValidate_NoCircularFragmentSpreads_NoSpreadingItselfDeeply
func TestValidate_NoCircularFragmentSpreads_NoSpreadingItselfDeeply(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.NoFragmentCyclesRule, `
fragment fragA on Dog { ...fragB }
fragment fragB on Dog { ...fragC }
fragment fragC on Dog { ...fragO }
fragment fragX on Dog { ...fragY }
fragment fragY on Dog { ...fragZ }
fragment fragZ on Dog { ...fragO }
fragment fragO on Dog { ...fragP }
fragment fragP on Dog { ...fragA, ...fragX }
`, []gqlerrors.FormattedError{
testutil.RuleError(`Cannot spread fragment "fragA" within itself via fragB, fragC, fragO, fragP.`,
2, 31,
3, 31,
4, 31,
8, 31,
9, 31),
testutil.RuleError(`Cannot spread fragment "fragO" within itself via fragP, fragX, fragY, fragZ.`,
8, 31,
9, 41,
5, 31,
6, 31,
7, 31),
})
}
开发者ID:housinganywhere,项目名称:graphql,代码行数:25,代码来源:rules_no_fragment_cycles_test.go
示例4: TestValidate_UniqueInputFieldNames_ManyDuplicateInputObjectFields
func TestValidate_UniqueInputFieldNames_ManyDuplicateInputObjectFields(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.UniqueInputFieldNamesRule, `
{
field(arg: { f1: "value", f1: "value", f1: "value" })
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`There can be only one input field named "f1".`, 3, 22, 3, 35),
testutil.RuleError(`There can be only one input field named "f1".`, 3, 22, 3, 48),
})
}
开发者ID:housinganywhere,项目名称:graphql,代码行数:10,代码来源:rules_unique_input_field_names_test.go
示例5: TestValidate_NoUnusedVariables_MultipleVariablesNotUsed
func TestValidate_NoUnusedVariables_MultipleVariablesNotUsed(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.NoUnusedVariablesRule, `
query Foo($a: String, $b: String, $c: String) {
field(b: $b)
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`Variable "$a" is never used in operation "Foo".`, 2, 17),
testutil.RuleError(`Variable "$c" is never used in operation "Foo".`, 2, 41),
})
}
开发者ID:housinganywhere,项目名称:graphql,代码行数:10,代码来源:rules_no_unused_variables_test.go
示例6: TestValidate_KnownArgumentNames_UnknownArgsAmongstKnownArgs
func TestValidate_KnownArgumentNames_UnknownArgsAmongstKnownArgs(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.KnownArgumentNamesRule, `
fragment oneGoodArgOneInvalidArg on Dog {
doesKnowCommand(whoknows: 1, dogCommand: SIT, unknown: true)
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`Unknown argument "whoknows" on field "doesKnowCommand" of type "Dog".`, 3, 25),
testutil.RuleError(`Unknown argument "unknown" on field "doesKnowCommand" of type "Dog".`, 3, 55),
})
}
开发者ID:housinganywhere,项目名称:graphql,代码行数:10,代码来源:rules_known_argument_names_test.go
示例7: TestValidate_UniqueArgumentNames_ManyDuplicateFieldArguments
func TestValidate_UniqueArgumentNames_ManyDuplicateFieldArguments(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.UniqueArgumentNamesRule, `
{
field(arg1: "value", arg1: "value", arg1: "value")
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`There can be only one argument named "arg1".`, 3, 15, 3, 30),
testutil.RuleError(`There can be only one argument named "arg1".`, 3, 15, 3, 45),
})
}
开发者ID:housinganywhere,项目名称:graphql,代码行数:10,代码来源:rules_unique_argument_names_test.go
示例8: TestValidate_NoUndefinedVariables_MultipleVariablesNotDefined
func TestValidate_NoUndefinedVariables_MultipleVariablesNotDefined(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.NoUndefinedVariablesRule, `
query Foo($b: String) {
field(a: $a, b: $b, c: $c)
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`Variable "$a" is not defined by operation "Foo".`, 3, 18, 2, 7),
testutil.RuleError(`Variable "$c" is not defined by operation "Foo".`, 3, 32, 2, 7),
})
}
开发者ID:housinganywhere,项目名称:graphql,代码行数:10,代码来源:rules_no_undefined_variables_test.go
示例9: TestValidate_VariablesAreInputTypes_1
func TestValidate_VariablesAreInputTypes_1(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.VariablesAreInputTypesRule, `
query Foo($a: Dog, $b: [[CatOrDog!]]!, $c: Pet) {
field(a: $a, b: $b, c: $c)
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`Variable "$a" cannot be non-input type "Dog".`, 2, 21),
testutil.RuleError(`Variable "$b" cannot be non-input type "[[CatOrDog!]]!".`, 2, 30),
testutil.RuleError(`Variable "$c" cannot be non-input type "Pet".`, 2, 50),
})
}
开发者ID:housinganywhere,项目名称:graphql,代码行数:11,代码来源:rules_variables_are_input_types_test.go
示例10: TestValidate_KnownDirectives_WithMisplacedDirectives
func TestValidate_KnownDirectives_WithMisplacedDirectives(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.KnownDirectivesRule, `
query Foo @include(if: true) {
name @operationOnly
...Frag @operationOnly
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`Directive "include" may not be used on QUERY.`, 2, 17),
testutil.RuleError(`Directive "operationOnly" may not be used on FIELD.`, 3, 14),
testutil.RuleError(`Directive "operationOnly" may not be used on FRAGMENT_SPREAD.`, 4, 17),
})
}
开发者ID:housinganywhere,项目名称:graphql,代码行数:12,代码来源:rules_known_directives_rule_test.go
示例11: TestValidate_ProvidedNonNullArguments_DirectiveArguments_WithDirectiveWithMissingTypes
func TestValidate_ProvidedNonNullArguments_DirectiveArguments_WithDirectiveWithMissingTypes(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.ProvidedNonNullArgumentsRule, `
{
dog @include {
name @skip
}
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`Directive "@include" argument "if" of type "Boolean!" is required but not provided.`, 3, 15),
testutil.RuleError(`Directive "@skip" argument "if" of type "Boolean!" is required but not provided.`, 4, 18),
})
}
开发者ID:housinganywhere,项目名称:graphql,代码行数:12,代码来源:rules_provided_non_null_arguments_test.go
示例12: TestValidate_ProvidedNonNullArguments_InvalidNonNullableValue_MissingMultipleNonNullableArguments
func TestValidate_ProvidedNonNullArguments_InvalidNonNullableValue_MissingMultipleNonNullableArguments(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.ProvidedNonNullArgumentsRule, `
{
complicatedArgs {
multipleReqs
}
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`Field "multipleReqs" argument "req1" of type "Int!" is required but not provided.`, 4, 13),
testutil.RuleError(`Field "multipleReqs" argument "req2" of type "Int!" is required but not provided.`, 4, 13),
})
}
开发者ID:housinganywhere,项目名称:graphql,代码行数:12,代码来源:rules_provided_non_null_arguments_test.go
示例13: TestValidate_UniqueVariableNames_DuplicateVariableNames
func TestValidate_UniqueVariableNames_DuplicateVariableNames(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.UniqueVariableNamesRule, `
query A($x: Int, $x: Int, $x: String) { __typename }
query B($x: String, $x: Int) { __typename }
query C($x: Int, $x: Int) { __typename }
`, []gqlerrors.FormattedError{
testutil.RuleError(`There can only be one variable named "x".`, 2, 16, 2, 25),
testutil.RuleError(`There can only be one variable named "x".`, 2, 16, 2, 34),
testutil.RuleError(`There can only be one variable named "x".`, 3, 16, 3, 28),
testutil.RuleError(`There can only be one variable named "x".`, 4, 16, 4, 25),
})
}
开发者ID:housinganywhere,项目名称:graphql,代码行数:12,代码来源:rules_unique_variable_names_test.go
示例14: TestValidate_AnonymousOperationMustBeAlone_MultipleAnonOperations
func TestValidate_AnonymousOperationMustBeAlone_MultipleAnonOperations(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.LoneAnonymousOperationRule, `
{
fieldA
}
{
fieldB
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`This anonymous operation must be the only defined operation.`, 2, 7),
testutil.RuleError(`This anonymous operation must be the only defined operation.`, 5, 7),
})
}
开发者ID:housinganywhere,项目名称:graphql,代码行数:13,代码来源:rules_lone_anonymous_operation_rule_test.go
示例15: TestValidate_NoCircularFragmentSpreads_NoSpreadingItselfDeeplyTwoPaths_AltTraverseOrder
func TestValidate_NoCircularFragmentSpreads_NoSpreadingItselfDeeplyTwoPaths_AltTraverseOrder(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.NoFragmentCyclesRule, `
fragment fragA on Dog { ...fragC }
fragment fragB on Dog { ...fragC }
fragment fragC on Dog { ...fragA, ...fragB }
`, []gqlerrors.FormattedError{
testutil.RuleError(`Cannot spread fragment "fragA" within itself via fragC.`,
2, 31,
4, 31),
testutil.RuleError(`Cannot spread fragment "fragC" within itself via fragB.`,
4, 41,
3, 31),
})
}
开发者ID:housinganywhere,项目名称:graphql,代码行数:14,代码来源:rules_no_fragment_cycles_test.go
示例16: TestValidate_FieldsOnCorrectType_ReportErrorsWhenTheTypeIsKnownAgain
func TestValidate_FieldsOnCorrectType_ReportErrorsWhenTheTypeIsKnownAgain(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.FieldsOnCorrectTypeRule, `
fragment typeKnownAgain on Pet {
unknown_pet_field {
... on Cat {
unknown_cat_field
}
}
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`Cannot query field "unknown_pet_field" on type "Pet".`, 3, 9),
testutil.RuleError(`Cannot query field "unknown_cat_field" on type "Cat".`, 5, 13),
})
}
开发者ID:housinganywhere,项目名称:graphql,代码行数:14,代码来源:rules_fields_on_correct_type_test.go
示例17: TestValidate_NoCircularFragmentSpreads_NoSpreadingItselfDirectly
func TestValidate_NoCircularFragmentSpreads_NoSpreadingItselfDirectly(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.NoFragmentCyclesRule, `
fragment fragA on Dog { ...fragA }
`, []gqlerrors.FormattedError{
testutil.RuleError(`Cannot spread fragment "fragA" within itself.`, 2, 31),
})
}
开发者ID:housinganywhere,项目名称:graphql,代码行数:7,代码来源:rules_no_fragment_cycles_test.go
示例18: TestValidate_NoCircularFragmentSpreads_SpreadingRecursivelyWithinFieldFails
func TestValidate_NoCircularFragmentSpreads_SpreadingRecursivelyWithinFieldFails(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.NoFragmentCyclesRule, `
fragment fragA on Human { relatives { ...fragA } },
`, []gqlerrors.FormattedError{
testutil.RuleError(`Cannot spread fragment "fragA" within itself.`, 2, 45),
})
}
开发者ID:housinganywhere,项目名称:graphql,代码行数:7,代码来源:rules_no_fragment_cycles_test.go
示例19: TestValidate_NoCircularFragmentSpreads_NoSpreadingItselfDeeplyAndImmediately
func TestValidate_NoCircularFragmentSpreads_NoSpreadingItselfDeeplyAndImmediately(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.NoFragmentCyclesRule, `
fragment fragA on Dog { ...fragB }
fragment fragB on Dog { ...fragB, ...fragC }
fragment fragC on Dog { ...fragA, ...fragB }
`, []gqlerrors.FormattedError{
testutil.RuleError(`Cannot spread fragment "fragB" within itself.`, 3, 31),
testutil.RuleError(`Cannot spread fragment "fragA" within itself via fragB, fragC.`,
2, 31,
3, 41,
4, 31),
testutil.RuleError(`Cannot spread fragment "fragB" within itself via fragC.`,
3, 41,
4, 41),
})
}
开发者ID:housinganywhere,项目名称:graphql,代码行数:16,代码来源:rules_no_fragment_cycles_test.go
示例20: TestValidate_NoUndefinedVariables_VariablesInFragmentNotDefinedByMultipleOperations
func TestValidate_NoUndefinedVariables_VariablesInFragmentNotDefinedByMultipleOperations(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.NoUndefinedVariablesRule, `
query Foo($b: String) {
...FragAB
}
query Bar($a: String) {
...FragAB
}
fragment FragAB on Type {
field(a: $a, b: $b)
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`Variable "$a" is not defined by operation "Foo".`, 9, 18, 2, 7),
testutil.RuleError(`Variable "$b" is not defined by operation "Bar".`, 9, 25, 5, 7),
})
}
开发者ID:housinganywhere,项目名称:graphql,代码行数:16,代码来源:rules_no_undefined_variables_test.go
注:本文中的github.com/housinganywhere/graphql/testutil.RuleError函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论