Add Future support and example app#2
Add Future support and example app#2noahemmet wants to merge 6 commits intoStevenLambion:update-to-vapor-3from
Future support and example app#2Conversation
| name: "VaporGraphQL", | ||
| targets: ["VaporGraphQL"]), | ||
| .library( | ||
| name: "StarWars", |
There was a problem hiding this comment.
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.
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.
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.
This was an odd bug, the decoder was failing here. This manual try? approach fixes it but there may be a better way?
| 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.
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
Futures, 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!