Skip to content

Commit

Permalink
Fixed: field selection merging rule reported error on non existing fi…
Browse files Browse the repository at this point in the history
…elds (ChilliCream#303)
  • Loading branch information
michaelstaib authored Oct 23, 2018
1 parent 8785899 commit 7f3b74a
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Core/Validation/FieldSelectionMergingVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ private bool SameResponseShape(FieldInfo fieldA, FieldInfo fieldB)
return typeA == typeB;
}

if (!typeA.IsCompositeType() || !typeB.IsCompositeType())
if (typeA != null && typeB != null
&& (!typeA.IsCompositeType() || !typeB.IsCompositeType()))
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Types/Configuration/SchemaOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace HotChocolate.Configuration
public class SchemaOptions
: ISchemaOptions
{
private const int _defaultMaxExecutionDepth = 8;
private const int _defaultMaxExecutionDepth = 16;
private const int _defaultMaxExecutionTimeout = 30;
private const int _defaultMaxDevExecutionTimeout = 360;

Expand Down
15 changes: 15 additions & 0 deletions src/Validation.Tests/FieldSelectionMergingRuleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -405,5 +405,20 @@ fragment interfaceFieldSelection on Cat {
// assert
Assert.False(result.HasErrors);
}

[Fact]
public void InvalidFieldsShouldNotRaiseValidationError()
{
// arrange
Schema schema = ValidationUtils.CreateSchema();
DocumentNode query = Parser.Default.Parse(
FileResource.Open("InvalidIntrospectionQuery.graphql"));

// act
QueryValidationResult result = Rule.Validate(schema, query);

// assert
Assert.False(result.HasErrors);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
query GetSchemaByTag {
__schema {
queryType {
name
}
mutationType {
name
}
subscriptionType {
name
}
types {
...IntrospectionFullType
}
directives {
name
description
locations
args {
...IntrospectionInputValue
}
}
}
}

fragment IntrospectionFullType on __Type {
kind
name
description
fields {
name
description
args {
...IntrospectionInputValue
}
type {
...IntrospectionTypeRef
}
isDeprecated
deprecationReason
}
inputFields {
...IntrospectionInputValue
}
interfaces {
...IntrospectionTypeRef
}
enumValues(includeDeprecated: true) {
name
description
isDeprecated
depreactionReason
}
possibleTypes {
...IntrospectionTypeRef
}
}

fragment IntrospectionInputValue on __InputValue {
name
description
type {
...IntrospectionTypeRef
}
defaultValue
}

fragment IntrospectionTypeRef on __Type {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
}
}
}
}
}
}
}
}

0 comments on commit 7f3b74a

Please sign in to comment.