func TestValidate_FieldsOnCorrectType_MetaFieldSelectionOnUnion(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.FieldsOnCorrectTypeRule, `
      fragment directFieldSelectionOnUnion on CatOrDog {
        __typename
      }
    `)
}
func TestValidate_UniqueArgumentNames_SameArgumentOnTwoDirectives(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.UniqueArgumentNamesRule, `
      {
        field @directive1(arg: "value") @directive2(arg: "value")
      }
    `)
}
func TestValidate_AnonymousOperationMustBeAlone_NoOperations(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.LoneAnonymousOperationRule, `
      fragment fragA on Type {
        field
      }
    `)
}
func TestValidate_KnownArgumentNames_NoArgsOnOptionalArg(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.KnownArgumentNamesRule, `
      fragment noArgOnOptionalArg on Dog {
        isHousetrained
      }
    `)
}
func TestValidate_UniqueArgumentNames_NoArgumentsOnDirective(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.UniqueArgumentNamesRule, `
      {
        field @directive
      }
    `)
}
func TestValidate_ProvidedNonNullArguments_DirectiveArguments_IgnoresUnknownDirectives(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.ProvidedNonNullArgumentsRule, `
        {
          dog @unknown
        }
    `)
}
func TestValidate_KnownArgumentNames_IgnoresArgsOfUnknownFields(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.KnownArgumentNamesRule, `
      fragment argOnUnknownField on Dog {
        unknownField(unknownArg: SIT)
      }
    `)
}
func TestValidate_NoCircularFragmentSpreads_DoesNotFalsePositiveOnUnknownFragment(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.NoFragmentCyclesRule, `
      fragment nameFragment on Pet {
        ...UnknownFragment
      }
    `)
}
예제 #9
0
func TestValidate_ScalarLeafs_ValidScalarSelection(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.ScalarLeafsRule, `
      fragment scalarSelection on Dog {
        barks
      }
    `)
}
func TestValidate_VariableDefaultValuesOfCorrectType_VariablesWithNoDefaultValues(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.DefaultValuesOfCorrectTypeRule, `
      query NullableValues($a: Int, $b: String, $c: ComplexInput) {
        dog { name }
      }
    `)
}
func TestValidate_VariableDefaultValuesOfCorrectType_RequiredVariablesWithoutDefaultValues(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.DefaultValuesOfCorrectTypeRule, `
      query RequiredValues($a: Int!, $b: String!) {
        dog { name }
      }
    `)
}
func TestValidate_FieldsOnCorrectType_IgnoresFieldsOnUnknownType(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.FieldsOnCorrectTypeRule, `
      fragment unknownSelection on UnknownType {
        unknownField
      }
    `)
}
func TestValidate_FieldsOnCorrectType_LyingAliasSelection(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.FieldsOnCorrectTypeRule, `
      fragment lyingAliasSelection on Dog {
        name : nickname
      }
    `)
}
func TestValidate_FieldsOnCorrectType_AliasedInterfaceFieldSelection(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.FieldsOnCorrectTypeRule, `
      fragment interfaceFieldSelection on Pet {
        otherName : name
      }
    `)
}
func TestValidate_FragmentsOnCompositeTypes_UnionIsValidFragmentType(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.FragmentsOnCompositeTypesRule, `
      fragment validFragment on CatOrDog {
        __typename
      }
    `)
}
예제 #16
0
func TestValidate_ScalarLeafs_ValidScalarSelectionWithArgs(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.ScalarLeafsRule, `
      fragment scalarSelectionWithArgs on Dog {
        doesKnowCommand(dogCommand: SIT)
      }
    `)
}
func TestValidate_NoUndefinedVariables_AllVariablesDefined(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.NoUndefinedVariablesRule, `
      query Foo($a: String, $b: String, $c: String) {
        field(a: $a, b: $b, c: $c)
      }
    `)
}
func TestValidate_UniqueFragmentNames_NoFragments(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.UniqueFragmentNamesRule, `
      {
        field
      }
    `)
}
func TestValidate_KnownArgumentNames_SingleArgIsKnown(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.KnownArgumentNamesRule, `
      fragment argOnRequiredArg on Dog {
        doesKnowCommand(dogCommand: SIT)
      }
    `)
}
func TestValidate_NoCircularFragmentSpreads_SpreadingTwiceIndirectlyIsNotCircular(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.NoFragmentCyclesRule, `
      fragment fragA on Dog { ...fragB, ...fragC }
      fragment fragB on Dog { ...fragC }
      fragment fragC on Dog { name }
    `)
}
func TestValidate_KnownArgumentNames_MultipleArgsInReverseOrderAreKnown(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.KnownArgumentNamesRule, `
      fragment multipleArgsReverseOrder on ComplicatedArgs {
        multipleReqs(req2: 2, req1: 1)
      }
    `)
}
func TestValidate_UniqueOperationNames_NoOperations(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.UniqueOperationNamesRule, `
      fragment fragA on Type {
        field
      }
    `)
}
func TestValidate_KnownArgumentNames_DirectiveArgsAreKnown(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.KnownArgumentNamesRule, `
      {
        dog @skip(if: true)
      }
    `)
}
func TestValidate_UniqueOperationNames_OneNamedOperation(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.UniqueOperationNamesRule, `
      query Foo {
        field
      }
    `)
}
func TestValidate_UniqueArgumentNames_ArgumentOnField(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.UniqueArgumentNamesRule, `
      {
        field(arg: "value")
      }
    `)
}
func TestValidate_FragmentsOnCompositeTypes_ObjectIsValidFragmentType(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.FragmentsOnCompositeTypesRule, `
      fragment validFragment on Dog {
        barks
      }
    `)
}
func TestValidate_UniqueArgumentNames_MultipleDirectiveArguments(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.UniqueArgumentNamesRule, `
      {
        field @directive(arg1: "value", arg2: "value", arg3: "value")
      }
    `)
}
func TestValidate_FragmentsOnCompositeTypes_InterfaceIsValidFragmentType(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.FragmentsOnCompositeTypesRule, `
      fragment validFragment on Pet {
        name
      }
    `)
}
func TestValidate_AnonymousOperationMustBeAlone_OneAnonOperation(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.LoneAnonymousOperationRule, `
      {
        field
      }
    `)
}
func TestValidate_UniqueInputFieldNames_MultipleInputObjectFields(t *testing.T) {
	testutil.ExpectPassesRule(t, graphql.UniqueInputFieldNamesRule, `
      {
        field(arg: { f1: "value", f2: "value", f3: "value" })
      }
    `)
}