-
-
Notifications
You must be signed in to change notification settings - Fork 749
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed and issue where the connection type was registered twice. (#842)
- Loading branch information
1 parent
ce67a7c
commit 0d82d59
Showing
14 changed files
with
266 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": ".NET Core Launch (web)", | ||
"type": "coreclr", | ||
"request": "launch", | ||
"preLaunchTask": "build", | ||
"program": "${workspaceFolder}/bin/Debug/netcoreapp2.1/AspNetCore.StarWars.dll", | ||
"args": [], | ||
"cwd": "${workspaceFolder}", | ||
"stopAtEntry": false, | ||
"serverReadyAction": { | ||
"action": "openExternally", | ||
"pattern": "^\\s*Now listening on:\\s+(https?://\\S+)" | ||
}, | ||
"env": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
}, | ||
"sourceFileMap": { | ||
"/Views": "${workspaceFolder}/Views" | ||
} | ||
}, | ||
{ | ||
"name": ".NET Core Attach", | ||
"type": "coreclr", | ||
"request": "attach", | ||
"processId": "${command:pickProcess}" | ||
} | ||
] | ||
} |
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,17 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "build", | ||
"command": "dotnet build", | ||
"type": "shell", | ||
"group": "build", | ||
"presentation": { | ||
"reveal": "silent" | ||
}, | ||
"problemMatcher": "$msCompile" | ||
} | ||
] | ||
} |
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
45 changes: 45 additions & 0 deletions
45
.../Types.Tests/Types/Relay/__snapshots__/ConnectionTypeTests.UsePaging_WithComplexType.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,45 @@ | ||
{ | ||
"Data": { | ||
"s": { | ||
"bar": { | ||
"edges": [ | ||
{ | ||
"cursor": "eyJfX3RvdGFsQ291bnQiOjcsIl9fcG9zaXRpb24iOjB9", | ||
"node": "a" | ||
}, | ||
{ | ||
"cursor": "eyJfX3RvdGFsQ291bnQiOjcsIl9fcG9zaXRpb24iOjF9", | ||
"node": "b" | ||
}, | ||
{ | ||
"cursor": "eyJfX3RvdGFsQ291bnQiOjcsIl9fcG9zaXRpb24iOjJ9", | ||
"node": "c" | ||
}, | ||
{ | ||
"cursor": "eyJfX3RvdGFsQ291bnQiOjcsIl9fcG9zaXRpb24iOjN9", | ||
"node": "d" | ||
}, | ||
{ | ||
"cursor": "eyJfX3RvdGFsQ291bnQiOjcsIl9fcG9zaXRpb24iOjR9", | ||
"node": "e" | ||
}, | ||
{ | ||
"cursor": "eyJfX3RvdGFsQ291bnQiOjcsIl9fcG9zaXRpb24iOjV9", | ||
"node": "f" | ||
}, | ||
{ | ||
"cursor": "eyJfX3RvdGFsQ291bnQiOjcsIl9fcG9zaXRpb24iOjZ9", | ||
"node": "g" | ||
} | ||
], | ||
"pageInfo": { | ||
"hasNextPage": false | ||
}, | ||
"totalCount": 7 | ||
} | ||
} | ||
}, | ||
"Extensions": {}, | ||
"Errors": [], | ||
"ContextData": {} | ||
} |
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
"node": "g" | ||
} | ||
], | ||
"items": [ | ||
"nodes": [ | ||
"f", | ||
"g" | ||
], | ||
|
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,46 @@ | ||
using System; | ||
using HotChocolate.Resolvers; | ||
|
||
namespace HotChocolate.Types.Relay | ||
{ | ||
public class ConnectionWithCountType<T> | ||
: ConnectionType<T> | ||
where T : IOutputType | ||
{ | ||
public ConnectionWithCountType() | ||
: base(descriptor => Configure(descriptor)) | ||
{ | ||
} | ||
|
||
public ConnectionWithCountType( | ||
Action<IObjectTypeDescriptor<IConnection>> configure) | ||
: base(descriptor => | ||
{ | ||
Configure(descriptor); | ||
configure?.Invoke(descriptor); | ||
}) | ||
{ | ||
} | ||
|
||
protected new static void Configure( | ||
IObjectTypeDescriptor<IConnection> descriptor) | ||
{ | ||
descriptor.Field("totalCount") | ||
.Type<NonNullType<IntType>>() | ||
.Resolver(ctx => GetTotalCount(ctx)); | ||
} | ||
|
||
private static IResolverResult<long> GetTotalCount( | ||
IResolverContext context) | ||
{ | ||
IConnection connection = context.Parent<IConnection>(); | ||
if (connection.PageInfo.TotalCount.HasValue) | ||
{ | ||
return ResolverResult.CreateValue( | ||
connection.PageInfo.TotalCount.Value); | ||
} | ||
return ResolverResult.CreateError<long>( | ||
"The total count was not provided by the connection."); | ||
} | ||
} | ||
} |
Oops, something went wrong.