-
Notifications
You must be signed in to change notification settings - Fork 730
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
Add graphql-ws
protocol support
#2168
Changes from 17 commits
6e7af18
d60ae4a
685d359
c36b779
b1fc644
6768fde
e8d1123
7f6c4b6
ad9fbb5
37336c5
348dcf0
3391f33
5b3aafb
6edea9b
4178c66
d63d078
fa3f459
118745d
3589cad
2a92350
9c92529
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,33 @@ | ||
{ | ||
"object": { | ||
"pins": [ | ||
{ | ||
"package": "CwlCatchException", | ||
"repositoryURL": "https://github.com/mattgallagher/CwlCatchException.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "35f9e770f54ce62dd8526470f14c6e137cef3eea", | ||
"version": "2.1.1" | ||
} | ||
}, | ||
{ | ||
"package": "CwlPreconditionTesting", | ||
"repositoryURL": "https://github.com/mattgallagher/CwlPreconditionTesting.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "c21f7bab5ca8eee0a9998bbd17ca1d0eb45d4688", | ||
"version": "2.1.0" | ||
} | ||
}, | ||
{ | ||
"package": "Nimble", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding Nimble to |
||
"repositoryURL": "https://github.com/Quick/Nimble", | ||
"state": { | ||
"branch": null, | ||
"revision": "c93f16c25af5770f0d3e6af27c9634640946b068", | ||
"version": "9.2.1" | ||
} | ||
}, | ||
{ | ||
"package": "SQLite.swift", | ||
"repositoryURL": "https://github.com/stephencelis/SQLite.swift.git", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include "../Shared/Workspace-Universal-Framework.xcconfig" | ||
|
||
INFOPLIST_FILE = Sources/SubscriptionAPI/Info.plist |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v12.22.10 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SimpleUploadServer needs to be upgraded to the latest Apollo Server at some point but for now we have to do this. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,8 @@ const server = new ApolloServer({ | |
} | ||
}); | ||
|
||
server.listen().then(({ url }) => { | ||
server.listen({ | ||
port: 4001 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Apollo Server documentation example defaults to port |
||
}).then(({ url }) => { | ||
console.info(`Upload server started at ${url}`); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Foundation | ||
@testable import ApolloWebSocket | ||
|
||
public class MockWebSocketDelegate: WebSocketClientDelegate { | ||
public var didReceiveMessage: ((String) -> Void)? | ||
|
||
public init() {} | ||
|
||
public func websocketDidConnect(socket: WebSocketClient) {} | ||
|
||
public func websocketDidDisconnect(socket: WebSocketClient, error: Error?) {} | ||
|
||
public func websocketDidReceiveMessage(socket: WebSocketClient, text: String) { | ||
didReceiveMessage?(text) | ||
} | ||
|
||
public func websocketDidReceiveData(socket: WebSocketClient, data: Data) {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ final class OperationMessage { | |
enum Types : String { | ||
case connectionInit = "connection_init" // Client -> Server | ||
case connectionTerminate = "connection_terminate" // Client -> Server | ||
case subscribe = "subscribe" // Client -> Server | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Messages that are additive so that we can continue to support both protocols. |
||
case start = "start" // Client -> Server | ||
case stop = "stop" // Client -> Server | ||
|
||
|
@@ -17,6 +18,10 @@ final class OperationMessage { | |
case data = "data" // Server -> Client | ||
case error = "error" // Server -> Client | ||
case complete = "complete" // Server -> Client | ||
case next = "next" // Server -> Client | ||
|
||
case ping = "ping" // Bidirectional | ||
case pong = "pong" // Bidirectional | ||
} | ||
|
||
let serializationFormat = JSONSerializationFormat.self | ||
|
@@ -34,7 +39,7 @@ final class OperationMessage { | |
|
||
init(payload: GraphQLMap? = nil, | ||
id: String? = nil, | ||
type: Types = .start) { | ||
type: Types) { | ||
var message: GraphQLMap = [:] | ||
if let payload = payload { | ||
message["payload"] = payload | ||
|
@@ -99,6 +104,12 @@ final class OperationMessage { | |
} | ||
} | ||
|
||
extension OperationMessage: CustomDebugStringConvertible { | ||
var debugDescription: String { | ||
rawMessage! | ||
} | ||
} | ||
|
||
struct ParseHandler { | ||
let type: String? | ||
let id: String? | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// @generated | ||
// This file was automatically generated and should not be edited. | ||
|
||
import Apollo | ||
import Foundation | ||
|
||
public final class IncrementingSubscription: GraphQLSubscription { | ||
/// The raw GraphQL definition of this operation. | ||
public let operationDefinition: String = | ||
""" | ||
subscription Incrementing { | ||
numberIncremented | ||
} | ||
""" | ||
|
||
public let operationName: String = "Incrementing" | ||
|
||
public let operationIdentifier: String? = "fe12b5f0dfc7fefa513cc8aecef043b45daf2d776fd000d3a7703f9798ecf233" | ||
|
||
public init() { | ||
} | ||
|
||
public struct Data: GraphQLSelectionSet { | ||
public static let possibleTypes: [String] = ["Subscription"] | ||
|
||
public static var selections: [GraphQLSelection] { | ||
return [ | ||
GraphQLField("numberIncremented", type: .scalar(Int.self)), | ||
] | ||
} | ||
|
||
public private(set) var resultMap: ResultMap | ||
|
||
public init(unsafeResultMap: ResultMap) { | ||
self.resultMap = unsafeResultMap | ||
} | ||
|
||
public init(numberIncremented: Int? = nil) { | ||
self.init(unsafeResultMap: ["__typename": "Subscription", "numberIncremented": numberIncremented]) | ||
} | ||
|
||
public var numberIncremented: Int? { | ||
get { | ||
return resultMap["numberIncremented"] as? Int | ||
} | ||
set { | ||
resultMap.updateValue(newValue, forKey: "numberIncremented") | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>en</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>FMWK</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>$(CURRENT_PROJECT_VERSION)</string> | ||
<key>CFBundleVersion</key> | ||
<string>$(CURRENT_PROJECT_VERSION)</string> | ||
<key>NSPrincipalClass</key> | ||
<string></string> | ||
</dict> | ||
</plist> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
//! Project version number for SubscriptionAPI. | ||
FOUNDATION_EXPORT double SubscriptionAPIVersionNumber; | ||
|
||
//! Project version string for SubscriptionAPI. | ||
FOUNDATION_EXPORT const unsigned char SubscriptionAPIVersionString[]; | ||
|
||
// In this header, you should import all the public headers of your framework using statements like #import <SubscriptionAPI/PublicHeader.h> | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"fe12b5f0dfc7fefa513cc8aecef043b45daf2d776fd000d3a7703f9798ecf233": { | ||
"name": "Incrementing", | ||
"source": "subscription Incrementing {\n numberIncremented\n}" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
type Query { | ||
currentNumber: Int | ||
} | ||
|
||
type Subscription { | ||
numberIncremented: Int | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
subscription Incrementing { | ||
numberIncremented | ||
} | ||
|
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.
Required to tell nvm to actually use the
.nvmrc
file created to lock SimpleUploadServer to node v12.