@wishknish/knishio-client-js 0.6.0 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.iife.js +41 -90
- package/package.json +19 -18
- package/src/AuthToken.js +1 -1
- package/src/KnishIOClient.js +8 -8
- package/src/Wallet.js +41 -3
- package/src/libraries/strings.js +4 -2
- package/src/libraries/urql/UrqlClientWrapper.js +166 -0
- package/src/mutation/MutationActiveSession.js +4 -4
- package/src/mutation/MutationLinkIdentifier.js +4 -4
- package/src/mutation/MutationProposeMolecule.js +4 -4
- package/src/mutation/MutationRequestAuthorizationGuest.js +4 -4
- package/src/query/Query.js +3 -3
- package/src/query/QueryActiveSession.js +4 -4
- package/src/query/QueryAtom.js +4 -4
- package/src/query/QueryBalance.js +4 -4
- package/src/query/QueryBatch.js +4 -4
- package/src/query/QueryBatchHistory.js +4 -4
- package/src/query/QueryContinuId.js +4 -4
- package/src/query/QueryMetaType.js +4 -4
- package/src/query/QueryMetaTypeViaAtom.js +4 -4
- package/src/query/QueryPolicy.js +4 -4
- package/src/query/QueryToken.js +4 -4
- package/src/query/QueryUserActivity.js +4 -4
- package/src/query/QueryWalletBundle.js +4 -4
- package/src/query/QueryWalletList.js +4 -4
- package/src/subscribe/ActiveSessionSubscribe.js +3 -3
- package/src/subscribe/ActiveWalletSubscribe.js +3 -3
- package/src/subscribe/CreateMoleculeSubscribe.js +3 -3
- package/src/subscribe/Subscribe.js +3 -3
- package/src/subscribe/WalletStatusSubscribe.js +3 -3
- package/src/types/index.js +2 -0
- package/src/libraries/apollo/ApolloClientWrapper.js +0 -143
- package/src/libraries/apollo/CipherLink.js +0 -116
- package/src/libraries/apollo/Client.js +0 -154
- package/src/libraries/apollo/ErrorHandler.js +0 -32
- package/src/libraries/apollo/SubscriptionManager.js +0 -60
- package/src/libraries/apollo/operationUtils.js +0 -26
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Manages GraphQL subscriptions
|
|
3
|
-
*/
|
|
4
|
-
class SubscriptionManager {
|
|
5
|
-
/**
|
|
6
|
-
* @param {Client} client - Apollo Client instance
|
|
7
|
-
*/
|
|
8
|
-
constructor (client) {
|
|
9
|
-
this.$__client = client
|
|
10
|
-
this.$__subscribers = {}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Set the client instance
|
|
15
|
-
* @param {Client} client - Apollo Client instance
|
|
16
|
-
*/
|
|
17
|
-
setClient (client) {
|
|
18
|
-
this.$__client = client
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Create a new subscription
|
|
23
|
-
* @param {Object} request - Subscription request
|
|
24
|
-
* @param {Function} closure - Callback function for subscription updates
|
|
25
|
-
* @returns {Object} Subscription object
|
|
26
|
-
*/
|
|
27
|
-
subscribe (request, closure) {
|
|
28
|
-
const subscription = this.$__client.subscribe(request).subscribe(closure)
|
|
29
|
-
this.$__subscribers[request.operationName] = subscription
|
|
30
|
-
return subscription
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Unsubscribe from a specific subscription
|
|
35
|
-
* @param {string} operationName - Name of the operation to unsubscribe from
|
|
36
|
-
*/
|
|
37
|
-
unsubscribe (operationName) {
|
|
38
|
-
if (this.$__subscribers[operationName]) {
|
|
39
|
-
this.$__subscribers[operationName].unsubscribe()
|
|
40
|
-
this.$__client.unsubscribeFromChannel(operationName)
|
|
41
|
-
delete this.$__subscribers[operationName]
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Unsubscribe from all subscriptions
|
|
47
|
-
*/
|
|
48
|
-
unsubscribeAll () {
|
|
49
|
-
Object.keys(this.$__subscribers).forEach(this.unsubscribe.bind(this))
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Clear all subscriptions without unsubscribing
|
|
54
|
-
*/
|
|
55
|
-
clear () {
|
|
56
|
-
this.$__subscribers = {}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export default SubscriptionManager
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extract the operation name from a GraphQL operation
|
|
3
|
-
* @param {Object} operation - GraphQL operation object
|
|
4
|
-
* @returns {string} Operation name
|
|
5
|
-
*/
|
|
6
|
-
export function operationName (operation) {
|
|
7
|
-
const operationDefinition = operation.query.definitions.find(
|
|
8
|
-
definitionNode => definitionNode.kind === 'OperationDefinition'
|
|
9
|
-
)
|
|
10
|
-
const fieldNode = operationDefinition.selectionSet.selections.find(
|
|
11
|
-
definitionNode => definitionNode.kind === 'Field'
|
|
12
|
-
)
|
|
13
|
-
return fieldNode.name.value
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Extract the operation type from a GraphQL operation
|
|
18
|
-
* @param {Object} operation - GraphQL operation object
|
|
19
|
-
* @returns {string} Operation type (query, mutation, subscription)
|
|
20
|
-
*/
|
|
21
|
-
export function operationType (operation) {
|
|
22
|
-
const operationDefinition = operation.query.definitions.find(
|
|
23
|
-
definitionNode => definitionNode.kind === 'OperationDefinition'
|
|
24
|
-
)
|
|
25
|
-
return operationDefinition.operation
|
|
26
|
-
}
|