Skip to content

Commit

Permalink
Modify tests such that _entities field is omitted in NonResolvableKey…
Browse files Browse the repository at this point in the history
… tests.
  • Loading branch information
danielreynolds1 committed Jun 12, 2024
1 parent c2af858 commit 92a5616
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using HotChocolate.Types.Descriptors.Definitions;
using HotChocolate.Types.Helpers;
using static HotChocolate.ApolloFederation.FederationContextData;
using static HotChocolate.ApolloFederation.ThrowHelper;
using static HotChocolate.Types.TagHelper;

namespace HotChocolate.ApolloFederation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public async Task AnnotateKeyToObjectTypeAnnotationBased()
.AddGraphQL()
.AddApolloFederation()
.AddQueryType<Query<TestTypeClassDirective>>()
.AddObjectType<TestTypeResolvableKeyClassDirective>()
.BuildSchemaAsync();

// act
Expand Down Expand Up @@ -111,7 +110,6 @@ public async Task AnnotateKeyToClassAttributeAnnotationBased()
.AddGraphQL()
.AddApolloFederation()
.AddQueryType<Query<TestTypePropertyDirective>>()
.AddObjectType<TestTypeResolvableKeyClassDirective>()
.BuildSchemaAsync();

// act
Expand Down Expand Up @@ -142,7 +140,6 @@ public async Task AnnotateKeyToClassAttributesAnnotationBased()
.AddGraphQL()
.AddApolloFederation()
.AddQueryType<Query<TestTypePropertyDirectives>>()
.AddObjectType<TestTypeResolvableKeyClassDirective>()
.BuildSchemaAsync();

// act
Expand Down Expand Up @@ -171,15 +168,14 @@ public async Task AnnotateInconsistentResolvableKeyToClassAttributesAnnotationBa
async () => await new ServiceCollection()
.AddGraphQL()
.AddApolloFederation()
.AddQueryType<Query<TestTypeInconsistentResolablePropertyDirectives>>()
.AddObjectType<TestTypeResolvableKeyClassDirective>()
.AddQueryType<Query<TestTypeInconsistentResolvablePropertyDirectives>>()
.BuildSchemaAsync());

// assert
Assert.Collection(ex.Errors,
item =>
{
Assert.Contains("The specified key attributes must shared the same resolvable values when annotated on multiple fields.", item.Message);
Assert.Contains("The specified key attributes must share the same resolvable values when annotated on multiple fields.", item.Message);
});
}

Expand All @@ -193,7 +189,6 @@ public async Task AnnotateKeyToInterfaceAttributesAnnotationBased()
.AddGraphQL()
.AddApolloFederation()
.AddQueryType<Query<TestTypeClassDirective>>()
.AddObjectType<TestTypeResolvableKeyClassDirective>()
.AddInterfaceType<ITestTypeInterfaceDirective>()
.BuildSchemaAsync();

Expand Down Expand Up @@ -294,12 +289,6 @@ public class Query<T>
public T someField(int id) => default!;
}

[Key("id")]
public class TestTypeResolvableKeyClassDirective : ITestTypeInterfaceDirective
{
public int Id { get; set; }
}

[Key("id", resolvable: false)]
public class TestTypeClassDirective : ITestTypeInterfaceDirective
{
Expand All @@ -326,7 +315,7 @@ public class TestTypePropertyDirectives
public string Name { get; set; } = default!;
}

public class TestTypeInconsistentResolablePropertyDirectives
public class TestTypeInconsistentResolvablePropertyDirectives
{
[Key(null!, resolvable: false)]
public int Id { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,17 @@
type QueryOfTestTypePropertyDirective {
someField(id: Int!): TestTypePropertyDirective!
_service: _Service!
_entities(representations: [_Any!]!): [_Entity]!
}

type TestTypePropertyDirective @key(fields: "id", resolvable: false) {
id: Int!
}

type TestTypeResolvableKeyClassDirective @key(fields: "id") {
id: Int!
}

"This type provides a field named sdl: String! which exposes the SDL of the service's schema. This SDL (schema definition language) is a printed version of the service's schema including the annotations of federation directives. This SDL does not include the additions of the federation spec."
type _Service {
sdl: String!
}

"Union of all types that key directive applied. This information is needed by the Apollo federation gateway."
union _Entity = TestTypeResolvableKeyClassDirective

"Used to indicate a combination of fields that can be used to uniquely identify and fetch an object or interface."
directive @key(fields: FieldSet! resolvable: Boolean = true) repeatable on OBJECT | INTERFACE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,18 @@
type QueryOfTestTypePropertyDirectives {
someField(id: Int!): TestTypePropertyDirectives!
_service: _Service!
_entities(representations: [_Any!]!): [_Entity]!
}

type TestTypePropertyDirectives @key(fields: "id name", resolvable: false) {
id: Int!
name: String!
}

type TestTypeResolvableKeyClassDirective @key(fields: "id") {
id: Int!
}

"This type provides a field named sdl: String! which exposes the SDL of the service's schema. This SDL (schema definition language) is a printed version of the service's schema including the annotations of federation directives. This SDL does not include the additions of the federation spec."
type _Service {
sdl: String!
}

"Union of all types that key directive applied. This information is needed by the Apollo federation gateway."
union _Entity = TestTypeResolvableKeyClassDirective

"Used to indicate a combination of fields that can be used to uniquely identify and fetch an object or interface."
directive @key(fields: FieldSet! resolvable: Boolean = true) repeatable on OBJECT | INTERFACE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,17 @@ interface ITestTypeInterfaceDirective @key(fields: "id", resolvable: false) {
type QueryOfTestTypeClassDirective {
someField(id: Int!): TestTypeClassDirective!
_service: _Service!
_entities(representations: [_Any!]!): [_Entity]!
}

type TestTypeClassDirective implements ITestTypeInterfaceDirective @key(fields: "id", resolvable: false) {
id: Int!
}

type TestTypeResolvableKeyClassDirective implements ITestTypeInterfaceDirective @key(fields: "id") {
id: Int!
}

"This type provides a field named sdl: String! which exposes the SDL of the service's schema. This SDL (schema definition language) is a printed version of the service's schema including the annotations of federation directives. This SDL does not include the additions of the federation spec."
type _Service {
sdl: String!
}

"Union of all types that key directive applied. This information is needed by the Apollo federation gateway."
union _Entity = TestTypeResolvableKeyClassDirective

"Used to indicate a combination of fields that can be used to uniquely identify and fetch an object or interface."
directive @key(fields: FieldSet! resolvable: Boolean = true) repeatable on OBJECT | INTERFACE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,17 @@
type QueryOfTestTypeClassDirective {
someField(id: Int!): TestTypeClassDirective!
_service: _Service!
_entities(representations: [_Any!]!): [_Entity]!
}

type TestTypeClassDirective @key(fields: "id", resolvable: false) {
id: Int!
}

type TestTypeResolvableKeyClassDirective @key(fields: "id") {
id: Int!
}

"This type provides a field named sdl: String! which exposes the SDL of the service's schema. This SDL (schema definition language) is a printed version of the service's schema including the annotations of federation directives. This SDL does not include the additions of the federation spec."
type _Service {
sdl: String!
}

"Union of all types that key directive applied. This information is needed by the Apollo federation gateway."
union _Entity = TestTypeResolvableKeyClassDirective

"Used to indicate a combination of fields that can be used to uniquely identify and fetch an object or interface."
directive @key(fields: FieldSet! resolvable: Boolean = true) repeatable on OBJECT | INTERFACE

Expand Down

0 comments on commit 92a5616

Please sign in to comment.