-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from d-exclaimation/graphql-swift
GraphQLSchema Migration, GraphQL Playground
- Loading branch information
Showing
43 changed files
with
530 additions
and
189 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
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,39 @@ | ||
// | ||
// Pioneer+Graphiti.swift | ||
// Pioneer | ||
// | ||
// Created by d-exclaimation on 9:46 PM. | ||
// | ||
|
||
import Graphiti | ||
import Vapor | ||
|
||
public extension Pioneer { | ||
/// - Parameters: | ||
/// - schema: GraphQL schema used to execute operations | ||
/// - resolver: Resolver used by the GraphQL schema | ||
/// - contextBuilder: Context builder from request | ||
/// - httpStrategy: HTTP strategy | ||
/// - websocketProtocol: Websocket sub-protocol | ||
/// - introspection: Allowing introspection | ||
/// - playground: Allowing playground | ||
init( | ||
schema: Schema<Resolver, Context>, | ||
resolver: Resolver, | ||
contextBuilder: @escaping (Request, Response) -> Context, | ||
httpStrategy: HTTPStrategy = .queryOnlyGet, | ||
websocketProtocol: WebsocketProtocol = .subscriptionsTransportWs, | ||
introspection: Bool = true, | ||
playground: Bool = true | ||
) { | ||
self.init( | ||
schema: schema.schema, | ||
resolver: resolver, | ||
contextBuilder: contextBuilder, | ||
httpStrategy: httpStrategy, | ||
websocketProtocol: websocketProtocol, | ||
introspection: introspection, | ||
playground: playground | ||
) | ||
} | ||
} |
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
24 changes: 24 additions & 0 deletions
24
Sources/Pioneer/Extensions/Vapor/CORSMIddleware+BananaCakePop.swift
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,24 @@ | ||
// | ||
// CORSMiddleware+BananaCakePop.swift | ||
// Pioneer | ||
// | ||
// Created by d-exclaimation. | ||
// | ||
|
||
import Vapor | ||
import NIOHTTP1 | ||
|
||
extension CORSMiddleware.Configuration { | ||
/// Setup CORS for GraphQL allowing Banana Cake Pop GraphQL IDE (Cloud Version) | ||
/// | ||
/// - Parameter urls: Extra Allowed origins | ||
/// - Returns: CORS Configuration | ||
public static func graphqlWithBananaCakePop(with urls: [String] = []) -> CORSMiddleware.Configuration { | ||
let allowedOrigin: CORSMiddleware.AllowOriginSetting = .any(["https://eat.bananacakepop.com/"] + urls) | ||
let allowedMethods: [HTTPMethod] = [.GET, .POST, .OPTIONS] | ||
let allowedHeaders: [HTTPHeaders.Name] = [ | ||
.secWebSocketProtocol, .accept, .authorization, .contentType, .origin, .userAgent, .accessControlAllowOrigin, .xRequestedWith | ||
] | ||
return .init(allowedOrigin: allowedOrigin, allowedMethods: allowedMethods, allowedHeaders: allowedHeaders) | ||
} | ||
} |
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
3 changes: 1 addition & 2 deletions
3
.../Pioneer/Vapor/EnvironmentVariables.swift → ...tensions/Vapor/EnvironmentVariables.swift
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
Oops, something went wrong.