-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from graphql-dotnet/implemented-members-in-int…
…erfaces Implemented members in interfaces
- Loading branch information
Showing
8 changed files
with
117 additions
and
46 deletions.
There are no files selected for viewing
Submodule graphql-dotnet
updated
8 files
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
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
62 changes: 62 additions & 0 deletions
62
test/GraphQL.Conventions.Tests/Adapters/Engine/GenericTypesInInterfaceTests.cs
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,62 @@ | ||
using GraphQL.Conventions.Adapters.Engine; | ||
using GraphQL.Conventions.Tests.Templates; | ||
using GraphQL.Conventions.Tests.Templates.Extensions; | ||
using GraphQL.Conventions.Types; | ||
using Xunit; | ||
|
||
namespace GraphQL.Conventions.Tests.Adapters.Engine | ||
{ | ||
public class GenericTypesInInterfaceTests : TestBase | ||
{ | ||
[Fact] | ||
public void Can_Construct_And_Describe_Schema_Using_Interfaces_With_Generic_Types() | ||
{ | ||
var engine = new GraphQLEngine(); | ||
engine.BuildSchema(typeof(SchemaDefinition<Query>)); | ||
var schema = engine.Describe(); | ||
schema.ShouldEqualWhenReformatted(@" | ||
type Account implements IAccount { | ||
id: Int! | ||
} | ||
interface IAccount { | ||
id: Int! | ||
} | ||
type Query { | ||
account: IAccount | ||
} | ||
"); | ||
} | ||
|
||
[Fact] | ||
public async void Can_Execute_Query_On_Schema_Using_Interfaces_With_Generic_Types() | ||
{ | ||
var engine = new GraphQLEngine(); | ||
engine.BuildSchema(typeof(SchemaDefinition<Query>)); | ||
var result = await engine | ||
.NewExecutor() | ||
.WithQueryString("{ account { id } }") | ||
.EnableValidation() | ||
.Execute(); | ||
|
||
result.ShouldHaveNoErrors(); | ||
result.Data.ShouldHaveFieldWithValue("account", "id", 123); | ||
} | ||
|
||
interface IEntity<T> | ||
{ | ||
T Id { get; } | ||
} | ||
|
||
interface IAccount : IEntity<int> { } | ||
|
||
class Account : IAccount | ||
{ | ||
public int Id { get; } = 123; | ||
} | ||
|
||
class Query | ||
{ | ||
public IAccount Account { get; } = new Account(); | ||
} | ||
} | ||
} |
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