diff --git a/Package.resolved b/Package.resolved index abfb4d6..9cf3a28 100644 --- a/Package.resolved +++ b/Package.resolved @@ -6,8 +6,8 @@ "repositoryURL": "https://github.com/swift-server/async-http-client.git", "state": { "branch": null, - "revision": "a72c5adce3986ff6b5092ae0464a8f2675087860", - "version": "1.2.3" + "revision": "5bee16a79922e3efcb5cea06ecd27e6f8048b56b", + "version": "1.13.1" } }, { @@ -15,8 +15,8 @@ "repositoryURL": "https://github.com/vapor/async-kit.git", "state": { "branch": null, - "revision": "5760c79afb8ebc24fd3251fdd9724af225fdf1f9", - "version": "1.3.0" + "revision": "929808e51fea04f01de0e911ce826ef70c4db4ea", + "version": "1.15.0" } }, { @@ -24,8 +24,8 @@ "repositoryURL": "https://github.com/vapor/console-kit.git", "state": { "branch": null, - "revision": "08f36a30e0893e6a52fefbf1c2db4a6bc1288ba2", - "version": "4.2.5" + "revision": "a7e67a1719933318b5ab7eaaed355cde020465b1", + "version": "4.5.0" } }, { @@ -33,8 +33,8 @@ "repositoryURL": "https://github.com/vapor/multipart-kit.git", "state": { "branch": null, - "revision": "73706f1883f2ba950d41f18aec7e3a53766d4a6d", - "version": "4.0.0" + "revision": "0d55c35e788451ee27222783c7d363cb88092fab", + "version": "4.5.2" } }, { @@ -42,8 +42,26 @@ "repositoryURL": "https://github.com/vapor/routing-kit.git", "state": { "branch": null, - "revision": "4cf052b78aebaf1b23f2264ce04d57b4b6eb5254", - "version": "4.2.0" + "revision": "ffac7b3a127ce1e85fb232f1a6271164628809ad", + "version": "4.6.0" + } + }, + { + "package": "swift-algorithms", + "repositoryURL": "https://github.com/apple/swift-algorithms.git", + "state": { + "branch": null, + "revision": "b14b7f4c528c942f121c8b860b9410b2bf57825e", + "version": "1.0.0" + } + }, + { + "package": "swift-atomics", + "repositoryURL": "https://github.com/apple/swift-atomics.git", + "state": { + "branch": null, + "revision": "ff3d2212b6b093db7f177d0855adbc4ef9c5f036", + "version": "1.0.3" } }, { @@ -51,8 +69,17 @@ "repositoryURL": "https://github.com/swift-server/swift-backtrace.git", "state": { "branch": null, - "revision": "f2fd8c4845a123419c348e0bc4b3839c414077d5", - "version": "1.2.0" + "revision": "f25620d5d05e2f1ba27154b40cafea2b67566956", + "version": "1.3.3" + } + }, + { + "package": "swift-collections", + "repositoryURL": "https://github.com/apple/swift-collections.git", + "state": { + "branch": null, + "revision": "937e904258d22af6e447a0b72c0bc67583ef64a2", + "version": "1.0.4" } }, { @@ -60,8 +87,8 @@ "repositoryURL": "https://github.com/apple/swift-crypto.git", "state": { "branch": null, - "revision": "8f4bfa5bc1951440c15710e9e893721aa4b2765c", - "version": "1.1.3" + "revision": "92a04c10fc5ce0504f8396aac7392126033e547c", + "version": "2.2.2" } }, { @@ -69,8 +96,8 @@ "repositoryURL": "https://github.com/apple/swift-log.git", "state": { "branch": null, - "revision": "173f567a2dfec11d74588eea82cecea555bdc0bc", - "version": "1.4.0" + "revision": "6fe203dc33195667ce1759bf0182975e4653ba1c", + "version": "1.4.4" } }, { @@ -78,8 +105,8 @@ "repositoryURL": "https://github.com/apple/swift-metrics.git", "state": { "branch": null, - "revision": "e382458581b05839a571c578e90060fff499f101", - "version": "2.1.1" + "revision": "9b39d811a83cf18b79d7d5513b06f8b290198b10", + "version": "2.3.3" } }, { @@ -87,8 +114,8 @@ "repositoryURL": "https://github.com/apple/swift-nio.git", "state": { "branch": null, - "revision": "43931b7a7daf8120a487601530c8bc03ce711992", - "version": "2.25.1" + "revision": "7e3b50b38e4e66f31db6cf4a784c6af148bac846", + "version": "2.46.0" } }, { @@ -96,8 +123,8 @@ "repositoryURL": "https://github.com/apple/swift-nio-extras.git", "state": { "branch": null, - "revision": "e5b5d191a80667a14827bfeb0ae4a511f7677942", - "version": "1.7.0" + "revision": "91dd2d61fb772e1311bb5f13b59266b579d77e42", + "version": "1.15.0" } }, { @@ -105,8 +132,8 @@ "repositoryURL": "https://github.com/apple/swift-nio-http2.git", "state": { "branch": null, - "revision": "d4060ac4d056a48d946298f04968f6f6080cc618", - "version": "1.16.2" + "revision": "d6656967f33ed8b368b38e4b198631fc7c484a40", + "version": "1.23.1" } }, { @@ -114,8 +141,8 @@ "repositoryURL": "https://github.com/apple/swift-nio-ssl.git", "state": { "branch": null, - "revision": "62bf5083df970e67c886210fa5b857eacf044b7c", - "version": "2.10.2" + "revision": "4fb7ead803e38949eb1d6fabb849206a72c580f3", + "version": "2.23.0" } }, { @@ -123,8 +150,17 @@ "repositoryURL": "https://github.com/apple/swift-nio-transport-services.git", "state": { "branch": null, - "revision": "5a352330c09a323e59ebd99afdf4ca3964c217bc", - "version": "1.9.1" + "revision": "c0d9a144cfaec8d3d596aadde3039286a266c15c", + "version": "1.15.0" + } + }, + { + "package": "swift-numerics", + "repositoryURL": "https://github.com/apple/swift-numerics", + "state": { + "branch": null, + "revision": "0a5bc04095a675662cf24757cc0640aa2204253b", + "version": "1.0.2" } }, { @@ -132,8 +168,8 @@ "repositoryURL": "https://github.com/vapor/vapor.git", "state": { "branch": null, - "revision": "bb87dcff4cf6d86d386308b4cb1393cefa4891a4", - "version": "4.39.2" + "revision": "eb2da0d749e185789970c32f7fd9c114a339fa13", + "version": "4.67.5" } }, { @@ -141,8 +177,8 @@ "repositoryURL": "https://github.com/vapor/websocket-kit.git", "state": { "branch": null, - "revision": "2b06a70dfcfa76a2e5079f60e3ae911511f09db0", - "version": "2.1.2" + "revision": "2d9d2188a08eef4a869d368daab21b3c08510991", + "version": "2.6.1" } } ] diff --git a/Sources/GraphiQLVapor/GraphiQLVapor.swift b/Sources/GraphiQLVapor/GraphiQLVapor.swift index 25d2c51..64d9843 100644 --- a/Sources/GraphiQLVapor/GraphiQLVapor.swift +++ b/Sources/GraphiQLVapor/GraphiQLVapor.swift @@ -7,22 +7,25 @@ extension Request { } public extension Application { - func enableGraphiQL(on pathComponents: PathComponent..., method: HTTPMethod = .GET, serverPath: PathComponent = "/graphql") { - graphQLServerPath = serverPath - + func enableGraphiQL(on pathComponents: PathComponent..., method: HTTPMethod = .GET, credentials: GraphiQLCredentialMode = .sameOrigin, serverPath: PathComponent = "/graphql") { self.on(method, pathComponents) { (request) -> Response in - request.serve(html: grahphiQLHTML) + request.serve(html: grahphiQLHTML(path: serverPath, credentialMode: credentials)) } } - func enableGraphiQL(method: HTTPMethod = .GET) { - self.enableGraphiQL(on: "", method: .GET, serverPath: "/graphql") + func enableGraphiQL(method: HTTPMethod = .GET, credentials: GraphiQLCredentialMode = .sameOrigin) { + self.enableGraphiQL(on: "", method: .GET, credentials: credentials, serverPath: "/graphql") } } -var graphQLServerPath: PathComponent = "/graphql" +public enum GraphiQLCredentialMode: String { + case include = "include" + case sameOrigin = "same-origin" + case omit = "omit" +} -let grahphiQLHTML = """ +func grahphiQLHTML(path: PathComponent, credentialMode: GraphiQLCredentialMode) -> String { + return """