@proscom/prostore-apollo-react
Advanced tools
Comparing version 0.0.9 to 0.0.10
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const react_1 = require("react"); | ||
var react_1 = require("react"); | ||
exports.ApolloClientsContext = react_1.createContext(null); | ||
class ApolloClientsManager { | ||
constructor(clients) { | ||
var ApolloClientsManager = /** @class */ (function () { | ||
function ApolloClientsManager(clients) { | ||
this.clients = clients; | ||
} | ||
getClient(key = 'default') { | ||
ApolloClientsManager.prototype.getClient = function (key) { | ||
if (key === void 0) { key = 'default'; } | ||
return this.clients[key]; | ||
} | ||
extract() { | ||
const result = {}; | ||
for (let [key, value] of Object.entries(this.clients)) { | ||
}; | ||
ApolloClientsManager.prototype.extract = function () { | ||
var result = {}; | ||
for (var _i = 0, _a = Object.entries(this.clients); _i < _a.length; _i++) { | ||
var _b = _a[_i], key = _b[0], value = _b[1]; | ||
result[key] = value.extract(); | ||
} | ||
return result; | ||
} | ||
} | ||
}; | ||
return ApolloClientsManager; | ||
}()); | ||
exports.ApolloClientsManager = ApolloClientsManager; | ||
function useContextApolloClient(clientOrName) { | ||
const apolloClientsContext = react_1.useContext(exports.ApolloClientsContext); | ||
var apolloClientsContext = react_1.useContext(exports.ApolloClientsContext); | ||
if (!clientOrName) { | ||
@@ -24,0 +27,0 @@ return apolloClientsContext.getClient(); |
import { DependencyList } from 'react'; | ||
import { IGraphqlQueryStoreParams } from '@proscom/prostore-apollo/lib/GraphqlQueryStore'; | ||
import { IGraphqlQueryStoreParams } from '@proscom/prostore-apollo'; | ||
import { ApolloClient } from 'apollo-client'; | ||
@@ -9,6 +9,6 @@ export interface IUseGraphqlQueryParams<Vars, Data> { | ||
} | ||
export declare function useGraphqlQuery<Vars, Data>({ client, queryOptions, variables }: IUseGraphqlQueryParams<Vars, Data>): import("@proscom/prostore-react/lib/useRequestStore").UseRequestStoreResult<import("@proscom/prostore/lib/RequestStore").IRequestState<Vars, Data>>; | ||
export declare function useGraphqlQuery<Vars, Data>({ client, queryOptions, variables }: IUseGraphqlQueryParams<Vars, Data>): import("@proscom/prostore-react").UseRequestStoreResult<import("@proscom/prostore").IRequestState<Vars, Data>>; | ||
export interface IUseGraphQueryVarsParams<Vars, Data> extends IUseGraphqlQueryParams<Vars, Data> { | ||
variableCreator: [() => Vars, DependencyList]; | ||
} | ||
export declare function useGraphqlQueryVars<Vars, Data>({ variableCreator, ...queryProps }: IUseGraphQueryVarsParams<Vars, Data>): import("@proscom/prostore-react/lib/useRequestStore").UseRequestStoreResult<import("@proscom/prostore/lib/RequestStore").IRequestState<Vars, Data>>; | ||
export declare function useGraphqlQueryVars<Vars, Data>({ variableCreator, ...queryProps }: IUseGraphQueryVarsParams<Vars, Data>): import("@proscom/prostore-react").UseRequestStoreResult<import("@proscom/prostore").IRequestState<Vars, Data>>; |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
@@ -14,18 +25,21 @@ var t = {}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const react_1 = require("react"); | ||
const GraphqlQueryStore_1 = require("@proscom/prostore-apollo/lib/GraphqlQueryStore"); | ||
const useRequestStore_1 = require("@proscom/prostore-react/lib/useRequestStore"); | ||
const ApolloClientsContext_1 = require("./ApolloClientsContext"); | ||
function useGraphqlQuery({ client, queryOptions, variables }) { | ||
const actualClient = ApolloClientsContext_1.useContextApolloClient(client); | ||
const store = react_1.useMemo(() => new GraphqlQueryStore_1.GraphqlQueryStore(Object.assign({ client: actualClient }, queryOptions)), [actualClient, queryOptions]); | ||
return useRequestStore_1.useRequestStore(store, variables); | ||
var react_1 = require("react"); | ||
var prostore_apollo_1 = require("@proscom/prostore-apollo"); | ||
var prostore_react_1 = require("@proscom/prostore-react"); | ||
var ApolloClientsContext_1 = require("./ApolloClientsContext"); | ||
function useGraphqlQuery(_a) { | ||
var client = _a.client, queryOptions = _a.queryOptions, variables = _a.variables; | ||
var actualClient = ApolloClientsContext_1.useContextApolloClient(client); | ||
var store = react_1.useMemo(function () { | ||
return new prostore_apollo_1.GraphqlQueryStore(__assign({ client: actualClient }, queryOptions)); | ||
}, [actualClient, queryOptions]); | ||
return prostore_react_1.useRequestStore(store, variables); | ||
} | ||
exports.useGraphqlQuery = useGraphqlQuery; | ||
function useGraphqlQueryVars(_a) { | ||
var { variableCreator } = _a, queryProps = __rest(_a, ["variableCreator"]); | ||
const variables = react_1.useMemo(...variableCreator); | ||
return useGraphqlQuery(Object.assign({}, queryProps, { variables })); | ||
var variableCreator = _a.variableCreator, queryProps = __rest(_a, ["variableCreator"]); | ||
var variables = react_1.useMemo.apply(void 0, variableCreator); | ||
return useGraphqlQuery(__assign({}, queryProps, { variables: variables })); | ||
} | ||
exports.useGraphqlQueryVars = useGraphqlQueryVars; | ||
//# sourceMappingURL=useGraphqlQuery.js.map |
import { DependencyList } from 'react'; | ||
import { IGraphqlWatchQueryStoreParams } from '@proscom/prostore-apollo/lib/GraphqlWatchQueryStore'; | ||
import { IGraphqlWatchQueryStoreParams } from '@proscom/prostore-apollo'; | ||
import { ApolloClient } from 'apollo-client'; | ||
@@ -16,6 +16,6 @@ export interface IUseGraphqlWatchQueryParams<Vars, Data> { | ||
*/ | ||
export declare function useGraphqlWatchQuery<Vars, Data>({ client, queryOptions, variables }: IUseGraphqlWatchQueryParams<Vars, Data>): import("@proscom/prostore-react/lib/useRequestStore").UseRequestStoreResult<import("@proscom/prostore/lib/RequestStore").IRequestState<Vars, Data>>; | ||
export declare function useGraphqlWatchQuery<Vars, Data>({ client, queryOptions, variables }: IUseGraphqlWatchQueryParams<Vars, Data>): import("@proscom/prostore-react").UseRequestStoreResult<import("@proscom/prostore").IRequestState<Vars, Data>>; | ||
export interface IUseGraphWatchQueryVarsParams<Vars, Data> extends IUseGraphqlWatchQueryParams<Vars, Data> { | ||
variableCreator: [() => Vars, DependencyList]; | ||
} | ||
export declare function useGraphqlWatchQueryVars<Vars, Data>({ variableCreator, ...queryProps }: IUseGraphWatchQueryVarsParams<Vars, Data>): import("@proscom/prostore-react/lib/useRequestStore").UseRequestStoreResult<import("@proscom/prostore/lib/RequestStore").IRequestState<Vars, Data>>; | ||
export declare function useGraphqlWatchQueryVars<Vars, Data>({ variableCreator, ...queryProps }: IUseGraphWatchQueryVarsParams<Vars, Data>): import("@proscom/prostore-react").UseRequestStoreResult<import("@proscom/prostore").IRequestState<Vars, Data>>; |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
@@ -14,6 +25,6 @@ var t = {}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const react_1 = require("react"); | ||
const GraphqlWatchQueryStore_1 = require("@proscom/prostore-apollo/lib/GraphqlWatchQueryStore"); | ||
const useRequestStore_1 = require("@proscom/prostore-react/lib/useRequestStore"); | ||
const ApolloClientsContext_1 = require("./ApolloClientsContext"); | ||
var react_1 = require("react"); | ||
var prostore_apollo_1 = require("@proscom/prostore-apollo"); | ||
var prostore_react_1 = require("@proscom/prostore-react"); | ||
var ApolloClientsContext_1 = require("./ApolloClientsContext"); | ||
/** | ||
@@ -26,14 +37,17 @@ * Создает graphql watchQuery и подписывается на него | ||
*/ | ||
function useGraphqlWatchQuery({ client, queryOptions, variables }) { | ||
const actualClient = ApolloClientsContext_1.useContextApolloClient(client); | ||
const store = react_1.useMemo(() => new GraphqlWatchQueryStore_1.GraphqlWatchQueryStore(Object.assign({ client: actualClient }, queryOptions)), [actualClient, queryOptions]); | ||
return useRequestStore_1.useRequestStore(store, variables); | ||
function useGraphqlWatchQuery(_a) { | ||
var client = _a.client, queryOptions = _a.queryOptions, variables = _a.variables; | ||
var actualClient = ApolloClientsContext_1.useContextApolloClient(client); | ||
var store = react_1.useMemo(function () { | ||
return new prostore_apollo_1.GraphqlWatchQueryStore(__assign({ client: actualClient }, queryOptions)); | ||
}, [actualClient, queryOptions]); | ||
return prostore_react_1.useRequestStore(store, variables); | ||
} | ||
exports.useGraphqlWatchQuery = useGraphqlWatchQuery; | ||
function useGraphqlWatchQueryVars(_a) { | ||
var { variableCreator } = _a, queryProps = __rest(_a, ["variableCreator"]); | ||
const variables = react_1.useMemo(...variableCreator); | ||
return useGraphqlWatchQuery(Object.assign({}, queryProps, { variables })); | ||
var variableCreator = _a.variableCreator, queryProps = __rest(_a, ["variableCreator"]); | ||
var variables = react_1.useMemo.apply(void 0, variableCreator); | ||
return useGraphqlWatchQuery(__assign({}, queryProps, { variables: variables })); | ||
} | ||
exports.useGraphqlWatchQueryVars = useGraphqlWatchQueryVars; | ||
//# sourceMappingURL=useGraphqlWatchQuery.js.map |
{ | ||
"name": "@proscom/prostore-apollo-react", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "> TODO: description", | ||
@@ -9,2 +9,3 @@ "author": "Andrew Starostin <a.starostin@proscom.ru>", | ||
"main": "lib/prostore-apollo-react.js", | ||
"module": "lib/es/prostore-apollo-react.js", | ||
"typings": "lib/prostore-apollo-react.d.ts", | ||
@@ -20,3 +21,3 @@ "directories": { | ||
"scripts": { | ||
"build": "tsc", | ||
"build": "tsc && tsc -p tsconfig.es.json", | ||
"watch": "tsc --watch --preserveWatchOutput", | ||
@@ -30,5 +31,5 @@ "watch-push": "nodemon --config yalc-push.nodemon.json", | ||
"dependencies": { | ||
"@proscom/prostore": "^0.0.9", | ||
"@proscom/prostore-apollo": "^0.0.9", | ||
"@proscom/prostore-react": "^0.0.9" | ||
"@proscom/prostore": "^0.0.10", | ||
"@proscom/prostore-apollo": "^0.0.10", | ||
"@proscom/prostore-react": "^0.0.10" | ||
}, | ||
@@ -45,3 +46,4 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "c3ef0173786c47df1b29ba06574f958ad91cf416" | ||
"sideEffects": false, | ||
"gitHead": "7b81abe2f49a11d3bfa193006bf14b8f9b6a96a5" | ||
} |
import {DependencyList, useMemo} from 'react'; | ||
import {GraphqlQueryStore, IGraphqlQueryStoreParams} from '@proscom/prostore-apollo/lib/GraphqlQueryStore'; | ||
import { useRequestStore } from '@proscom/prostore-react/lib/useRequestStore'; | ||
import {GraphqlQueryStore, IGraphqlQueryStoreParams} from '@proscom/prostore-apollo'; | ||
import { useRequestStore } from '@proscom/prostore-react'; | ||
import { useContextApolloClient } from './ApolloClientsContext'; | ||
@@ -5,0 +5,0 @@ import {ApolloClient} from 'apollo-client'; |
@@ -5,4 +5,4 @@ import {DependencyList, useMemo} from 'react'; | ||
IGraphqlWatchQueryStoreParams, | ||
} from '@proscom/prostore-apollo/lib/GraphqlWatchQueryStore'; | ||
import {useRequestStore} from '@proscom/prostore-react/lib/useRequestStore'; | ||
} from '@proscom/prostore-apollo'; | ||
import {useRequestStore} from '@proscom/prostore-react'; | ||
import {useContextApolloClient} from './ApolloClientsContext'; | ||
@@ -9,0 +9,0 @@ import {ApolloClient} from 'apollo-client'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33649
31
572
1
+ Added@proscom/prostore@0.0.10(transitive)
+ Added@proscom/prostore-apollo@0.0.10(transitive)
+ Added@proscom/prostore-react@0.0.10(transitive)
- Removed@proscom/prostore@0.0.9(transitive)
- Removed@proscom/prostore-apollo@0.0.9(transitive)
- Removed@proscom/prostore-react@0.0.9(transitive)
Updated@proscom/prostore@^0.0.10