-
Notifications
You must be signed in to change notification settings - Fork 3
Add Future
support and example app
#2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: update-to-vapor-3
Are you sure you want to change the base?
Conversation
@@ -9,17 +9,30 @@ let package = Package( | |||
.library( | |||
name: "VaporGraphQL", | |||
targets: ["VaporGraphQL"]), | |||
.library( | |||
name: "StarWars", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved these to a separate framework so they can be referenced from both the tests and the example app.
@@ -0,0 +1,11 @@ | |||
import Vapor | |||
|
|||
/// Creates an instance of Application. This is called from main.swift in the run target. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are just Vapor's default new project files.
@@ -74,7 +74,7 @@ extension Droid : MapFallibleRepresentable {} | |||
* This implements the following type system shorthand: | |||
* enum Episode { NEWHOPE, EMPIRE, JEDI } | |||
*/ | |||
let EpisodeEnum = try! GraphQLEnumType( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I lowercased these instances to be more Swift-y.
public init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
query = try container.decode(String.self, forKey: .query) | ||
// the decoder has trouble decoding a nil `[String: Map]`, so we'll use an optional throw. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was an odd bug, the decoder was failing here. This manual try?
approach fixes it but there may be a better way?
@@ -94,7 +94,7 @@ extension GraphQLService { | |||
/// Returns an introspection of the GraphQL schema. | |||
public func executeIntrospectionQuery(for req: Request) -> Future<Map> { | |||
return self.execute( | |||
GraphQLExecutionRequest(query: introspectionQuery, variables: [:], operationName: ""), | |||
GraphQLExecutionRequest(query: introspectionQuery, variables: [:], operationName: nil), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was another weird bug: we check for isEmpty
later, and it needs to fail in order to properly render. Passing in nil
fixes it.
Is there a branch o can run now |
You can add .package(url: "https://github.com/noahemmet/GraphQLRouteCollection.git", .branch("futures")) to your |
Hi! I've updated this framework to
Future
s, instead of GCD.(Note that until GraphQLSwift/GraphQL#43 is merged, I'm pointing to my custom branch of GraphQLSwift.)
Thanks very much for this framework, I think it will make setting up a Swift GraphQL server much, much easier!