Initial Sample.

This commit is contained in:
2024-06-03 20:23:50 +05:30
parent ef2b65f673
commit 5269ec3c66
2575 changed files with 282312 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var tslib = require('tslib');
var core = require('../core');
var utilities = require('../../utilities');
function setContext(setter) {
return new core.ApolloLink(function (operation, forward) {
var request = tslib.__rest(operation, []);
return new utilities.Observable(function (observer) {
var handle;
var closed = false;
Promise.resolve(request)
.then(function (req) { return setter(req, operation.getContext()); })
.then(operation.setContext)
.then(function () {
if (closed)
return;
handle = forward(operation).subscribe({
next: observer.next.bind(observer),
error: observer.error.bind(observer),
complete: observer.complete.bind(observer),
});
})
.catch(observer.error.bind(observer));
return function () {
closed = true;
if (handle)
handle.unsubscribe();
};
});
});
}
exports.setContext = setContext;
//# sourceMappingURL=context.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"context.cjs","sources":["index.js"],"sourcesContent":["import { __rest } from \"tslib\";\nimport { ApolloLink } from \"../core/index.js\";\nimport { Observable } from \"../../utilities/index.js\";\nexport function setContext(setter) {\n return new ApolloLink(function (operation, forward) {\n var request = __rest(operation, []);\n return new Observable(function (observer) {\n var handle;\n var closed = false;\n Promise.resolve(request)\n .then(function (req) { return setter(req, operation.getContext()); })\n .then(operation.setContext)\n .then(function () {\n // if the observer is already closed, no need to subscribe.\n if (closed)\n return;\n handle = forward(operation).subscribe({\n next: observer.next.bind(observer),\n error: observer.error.bind(observer),\n complete: observer.complete.bind(observer),\n });\n })\n .catch(observer.error.bind(observer));\n return function () {\n closed = true;\n if (handle)\n handle.unsubscribe();\n };\n });\n });\n}\n//# sourceMappingURL=index.js.map"],"names":["ApolloLink","__rest","Observable"],"mappings":";;;;;;;;AAGO,SAAS,UAAU,CAAC,MAAM,EAAE;AACnC,IAAI,OAAO,IAAIA,eAAU,CAAC,UAAU,SAAS,EAAE,OAAO,EAAE;AACxD,QAAQ,IAAI,OAAO,GAAGC,YAAM,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AAC5C,QAAQ,OAAO,IAAIC,oBAAU,CAAC,UAAU,QAAQ,EAAE;AAClD,YAAY,IAAI,MAAM,CAAC;AACvB,YAAY,IAAI,MAAM,GAAG,KAAK,CAAC;AAC/B,YAAY,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;AACpC,iBAAiB,IAAI,CAAC,UAAU,GAAG,EAAE,EAAE,OAAO,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC;AACrF,iBAAiB,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;AAC3C,iBAAiB,IAAI,CAAC,YAAY;AAElC,gBAAgB,IAAI,MAAM;AAC1B,oBAAoB,OAAO;AAC3B,gBAAgB,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC;AACtD,oBAAoB,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;AACtD,oBAAoB,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;AACxD,oBAAoB,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC;AAC9D,iBAAiB,CAAC,CAAC;AACnB,aAAa,CAAC;AACd,iBAAiB,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;AACtD,YAAY,OAAO,YAAY;AAC/B,gBAAgB,MAAM,GAAG,IAAI,CAAC;AAC9B,gBAAgB,IAAI,MAAM;AAC1B,oBAAoB,MAAM,CAAC,WAAW,EAAE,CAAC;AACzC,aAAa,CAAC;AACd,SAAS,CAAC,CAAC;AACX,KAAK,CAAC,CAAC;AACP;;;;"}

View File

@@ -0,0 +1,38 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var tslib = require('tslib');
var core = require('../core');
var utilities = require('../../utilities');
function setContext(setter) {
return new core.ApolloLink(function (operation, forward) {
var request = tslib.__rest(operation, []);
return new utilities.Observable(function (observer) {
var handle;
var closed = false;
Promise.resolve(request)
.then(function (req) { return setter(req, operation.getContext()); })
.then(operation.setContext)
.then(function () {
if (closed)
return;
handle = forward(operation).subscribe({
next: observer.next.bind(observer),
error: observer.error.bind(observer),
complete: observer.complete.bind(observer),
});
})
.catch(observer.error.bind(observer));
return function () {
closed = true;
if (handle)
handle.unsubscribe();
};
});
});
}
exports.setContext = setContext;
//# sourceMappingURL=context.cjs.map

View File

@@ -0,0 +1,6 @@
import type { GraphQLRequest } from "../core/index.js";
import { ApolloLink } from "../core/index.js";
import type { DefaultContext } from "../../core/index.js";
export type ContextSetter = (operation: GraphQLRequest, prevContext: DefaultContext) => Promise<DefaultContext> | DefaultContext;
export declare function setContext(setter: ContextSetter): ApolloLink;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1,32 @@
import { __rest } from "tslib";
import { ApolloLink } from "../core/index.js";
import { Observable } from "../../utilities/index.js";
export function setContext(setter) {
return new ApolloLink(function (operation, forward) {
var request = __rest(operation, []);
return new Observable(function (observer) {
var handle;
var closed = false;
Promise.resolve(request)
.then(function (req) { return setter(req, operation.getContext()); })
.then(operation.setContext)
.then(function () {
// if the observer is already closed, no need to subscribe.
if (closed)
return;
handle = forward(operation).subscribe({
next: observer.next.bind(observer),
error: observer.error.bind(observer),
complete: observer.complete.bind(observer),
});
})
.catch(observer.error.bind(observer));
return function () {
closed = true;
if (handle)
handle.unsubscribe();
};
});
});
}
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/link/context/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAQtD,MAAM,UAAU,UAAU,CAAC,MAAqB;IAC9C,OAAO,IAAI,UAAU,CAAC,UAAC,SAAoB,EAAE,OAAiB;QAC5D,IAAW,OAAO,UAAK,SAAS,EAA1B,EAAc,CAAY,CAAC;QAEjC,OAAO,IAAI,UAAU,CAAC,UAAC,QAAQ;YAC7B,IAAI,MAA8B,CAAC;YACnC,IAAI,MAAM,GAAG,KAAK,CAAC;YACnB,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;iBACrB,IAAI,CAAC,UAAC,GAAG,IAAK,OAAA,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,UAAU,EAAE,CAAC,EAAnC,CAAmC,CAAC;iBAClD,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;iBAC1B,IAAI,CAAC;gBACJ,2DAA2D;gBAC3D,IAAI,MAAM;oBAAE,OAAO;gBACnB,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC;oBACpC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;oBAClC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;oBACpC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC;iBAC3C,CAAC,CAAC;YACL,CAAC,CAAC;iBACD,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YAExC,OAAO;gBACL,MAAM,GAAG,IAAI,CAAC;gBACd,IAAI,MAAM;oBAAE,MAAM,CAAC,WAAW,EAAE,CAAC;YACnC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Operation, GraphQLRequest, NextLink } from \"../core/index.js\";\nimport { ApolloLink } from \"../core/index.js\";\nimport type { ObservableSubscription } from \"../../utilities/index.js\";\nimport { Observable } from \"../../utilities/index.js\";\nimport type { DefaultContext } from \"../../core/index.js\";\n\nexport type ContextSetter = (\n operation: GraphQLRequest,\n prevContext: DefaultContext\n) => Promise<DefaultContext> | DefaultContext;\n\nexport function setContext(setter: ContextSetter): ApolloLink {\n return new ApolloLink((operation: Operation, forward: NextLink) => {\n const { ...request } = operation;\n\n return new Observable((observer) => {\n let handle: ObservableSubscription;\n let closed = false;\n Promise.resolve(request)\n .then((req) => setter(req, operation.getContext()))\n .then(operation.setContext)\n .then(() => {\n // if the observer is already closed, no need to subscribe.\n if (closed) return;\n handle = forward(operation).subscribe({\n next: observer.next.bind(observer),\n error: observer.error.bind(observer),\n complete: observer.complete.bind(observer),\n });\n })\n .catch(observer.error.bind(observer));\n\n return () => {\n closed = true;\n if (handle) handle.unsubscribe();\n };\n });\n });\n}\n"]}

View File

@@ -0,0 +1,8 @@
{
"name": "@apollo/client/link/context",
"type": "module",
"main": "context.cjs",
"module": "index.js",
"types": "index.d.ts",
"sideEffects": false
}