Skip to content

Commit c64ed9f

Browse files
committed
make EfInterfaceGraphType inherit from AutoRegisteringInterfaceGraphType
1 parent f49aa33 commit c64ed9f

File tree

4 files changed

+26
-21
lines changed

4 files changed

+26
-21
lines changed

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project>
33
<PropertyGroup>
44
<NoWarn>CS1591;NU5104;CS1573;CS9107;NU1608;NU1109</NoWarn>
5-
<Version>32.3.1</Version>
5+
<Version>32.4.0-beta.1</Version>
66
<LangVersion>preview</LangVersion>
77
<AssemblyVersion>1.0.0</AssemblyVersion>
88
<PackageTags>EntityFrameworkCore, EntityFramework, GraphQL</PackageTags>

src/GraphQL.EntityFramework/GraphApi/EfInterfaceGraphType.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
namespace GraphQL.EntityFramework;
22

3-
public class EfInterfaceGraphType<TDbContext, TSource>(IEfGraphQLService<TDbContext> graphQlService) :
4-
InterfaceGraphType<TSource>
3+
public class EfInterfaceGraphType<TDbContext, TSource> :
4+
AutoRegisteringInterfaceGraphType<TSource>
55
where TDbContext : DbContext
66
{
7-
public IEfGraphQLService<TDbContext> GraphQlService { get; } = graphQlService;
7+
public EfInterfaceGraphType(IEfGraphQLService<TDbContext> graphQlService):this(graphQlService, null)
8+
{
9+
}
10+
11+
public EfInterfaceGraphType(IEfGraphQLService<TDbContext> graphQlService,params Expression<Func<TSource, object?>>[]? excludedProperties) :
12+
base(excludedProperties) =>
13+
GraphQlService = graphQlService;
14+
15+
public IEfGraphQLService<TDbContext> GraphQlService { get; }
816

917
public ConnectionBuilder<TSource> AddNavigationConnectionField<TReturn>(
1018
string name,

src/Tests/IntegrationTests/Graphs/Inheritance/BaseGraphType.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22
EfInterfaceGraphType<IntegrationDbContext, BaseEntity>
33
{
44
public BaseGraphType(IEfGraphQLService<IntegrationDbContext> graphQlService) :
5-
base(graphQlService)
6-
{
7-
Field(_ => _.Id);
8-
Field(_ => _.Property, nullable: true);
5+
base(graphQlService) =>
96
AddNavigationConnectionField<DerivedChildEntity>(
107
name: "childrenFromInterface",
118
includeNames: ["ChildrenFromBase"]);
12-
}
139
}

src/Tests/IntegrationTests/IntegrationTests.SchemaPrint.verified.txt

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -461,20 +461,21 @@ type BaseConnection {
461461
"A list of all of the edges returned in the connection."
462462
edges: [BaseEdge]
463463
"A list of all of the objects returned in the connection. This is a convenience field provided for quickly exploring the API; rather than querying for \"{ edges { node } }\" when no edge data is needed, this field can be used instead. Note that when clients like Relay need to fetch the \"cursor\" field on the edge to enable efficient pagination, this shortcut cannot be used, and the full \"{ edges { node } } \" version should be used instead."
464-
items: [Base]
464+
items: [BaseEntity]
465465
}
466466

467467
"An edge in a connection from an object to another object of type `Base`."
468468
type BaseEdge {
469469
"A cursor for use in pagination"
470470
cursor: String!
471471
"The item at the end of the edge"
472-
node: Base
472+
node: BaseEntity
473473
}
474474

475-
interface Base {
475+
interface BaseEntity {
476476
id: ID!
477477
property: String
478+
childrenFromBase: [DerivedChild!]!
478479
childrenFromInterface(
479480
"Only return edges after the specified cursor."
480481
after: String,
@@ -489,6 +490,13 @@ interface Base {
489490
ids: [ID!]): DerivedChildConnection!
490491
}
491492

493+
type DerivedChild {
494+
id: ID!
495+
parentId: ID
496+
property: String
497+
typedParentId: ID
498+
}
499+
492500
"A connection from an object to a list of objects of type `DerivedChild`."
493501
type DerivedChildConnection {
494502
"A count of the total number of objects in this connection, ignoring pagination. This allows a client to fetch the first five objects by passing \"5\" as the argument to `first`, then fetch the total count so it could display \"5 of 83\", for example. In cases where we employ infinite scrolling or don't have an exact count of entries, this field will return `null`."
@@ -509,13 +517,6 @@ type DerivedChildEdge {
509517
node: DerivedChild!
510518
}
511519

512-
type DerivedChild {
513-
id: ID!
514-
parentId: ID
515-
property: String
516-
typedParentId: ID
517-
}
518-
519520
type ManyToManyLeft {
520521
rights(id: ID, ids: [ID!], where: [WhereExpression!], orderBy: [OrderBy!], skip: Int, take: Int): [ManyToManyRight!]!
521522
id: String!
@@ -567,7 +568,7 @@ type Mutation {
567568
parentEntityMutation(id: ID, ids: [ID!], where: [WhereExpression!]): Parent!
568569
}
569570

570-
type Derived implements Base {
571+
type Derived implements BaseEntity {
571572
childrenFromInterface(
572573
"Only return edges after the specified cursor."
573574
after: String,
@@ -585,7 +586,7 @@ type Derived implements Base {
585586
property: String
586587
}
587588

588-
type DerivedWithNavigation implements Base {
589+
type DerivedWithNavigation implements BaseEntity {
589590
childrenFromInterface(
590591
"Only return edges after the specified cursor."
591592
after: String,

0 commit comments

Comments
 (0)