-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7ec5ed1
commit 1799680
Showing
5 changed files
with
140 additions
and
10 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,28 @@ | ||
|
||
import Foundation | ||
import NIO | ||
import ContextKit | ||
import GraphQL | ||
|
||
public protocol Node: GraphQLObject { | ||
func id(context: MutableContext, eventLoop: EventLoopGroup) -> EventLoopFuture<String> | ||
|
||
static func find(id: String, context: MutableContext, eventLoop: EventLoopGroup ) -> EventLoopFuture<Node?> | ||
} | ||
|
||
let GraphQLNodeIdField: GraphQLField = { | ||
return GraphQLField(type: GraphQLNonNull(GraphQLID), | ||
description: "The id of the object", | ||
deprecationReason: nil, | ||
args: [:]) { (source, _, context, eventLoop, _) -> Future<Any?> in | ||
|
||
return (source as! Node).id(context: context as! MutableContext, eventLoop: eventLoop).map { $0 } | ||
} | ||
}() | ||
|
||
let GraphQLNode: GraphQLInterfaceType = { | ||
let fields = [ | ||
"id" : GraphQLNodeIdField | ||
] | ||
return try! GraphQLInterfaceType(name: "Node", fields: fields, resolveType: nil) | ||
}() |
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