-
-
Notifications
You must be signed in to change notification settings - Fork 747
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed: Relay node field did not show in SDL (#1175)
- Loading branch information
1 parent
6cf4e40
commit 94cc778
Showing
6 changed files
with
80 additions
and
21 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System.Threading.Tasks; | ||
using Snapshooter.Xunit; | ||
using Xunit; | ||
|
||
namespace HotChocolate.Types.Relay | ||
{ | ||
public class RelaySchemaTests | ||
{ | ||
[Fact] | ||
public void EnableRelay_Node_Field_On_Query_Exists() | ||
{ | ||
// arrange | ||
// act | ||
ISchema schema = SchemaBuilder.New() | ||
.AddQueryType<QueryType>() | ||
.EnableRelaySupport() | ||
.Create(); | ||
|
||
// assert | ||
schema.ToString().MatchSnapshot(); | ||
} | ||
|
||
public class QueryType | ||
: ObjectType | ||
{ | ||
protected override void Configure(IObjectTypeDescriptor descriptor) | ||
{ | ||
descriptor.Field("some").Type<SomeType>().Resolver(new object()); | ||
} | ||
} | ||
|
||
public class SomeType | ||
: ObjectType | ||
{ | ||
protected override void Configure(IObjectTypeDescriptor descriptor) | ||
{ | ||
descriptor.Name("Some") | ||
.AsNode() | ||
.NodeResolver((context, id) => Task.FromResult(new object())); | ||
descriptor.Field("id").Type<NonNullType<IdType>>().Resolver("bar"); | ||
} | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...ts/Types/Relay/__snapshots__/RelaySchemaTests.EnableRelay_Node_Field_On_Query_Exists.snap
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,20 @@ | ||
schema { | ||
query: QueryType | ||
} | ||
|
||
"The node interface is implemented by entities that have a gloabl unique identifier." | ||
interface Node { | ||
id: ID! | ||
} | ||
|
||
type QueryType { | ||
node(id: ID!): Node | ||
some: Some | ||
} | ||
|
||
type Some implements Node { | ||
id: ID! | ||
} | ||
|
||
"The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `\"4\"`) or integer (such as `4`) input value will be accepted as an ID." | ||
scalar ID |
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