@subsquid+openreader+3.1.3.patch 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. diff --git a/node_modules/@subsquid/openreader/lib/context.d.ts b/node_modules/@subsquid/openreader/lib/context.d.ts
  2. index ccb64b5..faa6199 100644
  3. --- a/node_modules/@subsquid/openreader/lib/context.d.ts
  4. +++ b/node_modules/@subsquid/openreader/lib/context.d.ts
  5. @@ -1,7 +1,9 @@
  6. import { Dialect } from './dialect';
  7. import { Query } from './sql/query';
  8. import { Limit } from './util/limit';
  9. +import { Request } from 'express'
  10. export interface Context {
  11. + req: Request;
  12. openreader: OpenreaderContext;
  13. }
  14. export interface OpenreaderContext {
  15. @@ -10,5 +12,6 @@ export interface OpenreaderContext {
  16. subscription<T>(query: Query<T>): AsyncIterable<T>;
  17. responseSizeLimit?: Limit;
  18. subscriptionResponseSizeLimit?: Limit;
  19. + req: Request
  20. }
  21. //# sourceMappingURL=context.d.ts.map
  22. \ No newline at end of file
  23. diff --git a/node_modules/@subsquid/openreader/lib/server.d.ts b/node_modules/@subsquid/openreader/lib/server.d.ts
  24. index 7f5df76..066e4b2 100644
  25. --- a/node_modules/@subsquid/openreader/lib/server.d.ts
  26. +++ b/node_modules/@subsquid/openreader/lib/server.d.ts
  27. @@ -7,6 +7,7 @@ import type { Pool } from 'pg';
  28. import { Context } from './context';
  29. import type { Dialect } from './dialect';
  30. import type { Model } from './model';
  31. +import { ExpressContext } from 'apollo-server-express'
  32. export interface ServerOptions {
  33. port: number | string;
  34. model: Model;
  35. @@ -28,7 +29,7 @@ export declare type Dispose = () => Promise<void>;
  36. export interface ApolloOptions {
  37. port: number | string;
  38. disposals: Dispose[];
  39. - context: () => Context;
  40. + context: (ctx: ExpressContext) => Context;
  41. schema: GraphQLSchema;
  42. plugins?: PluginDefinition[];
  43. subscriptions?: boolean;
  44. diff --git a/node_modules/@subsquid/openreader/lib/server.js b/node_modules/@subsquid/openreader/lib/server.js
  45. index 6fb0711..854393f 100644
  46. --- a/node_modules/@subsquid/openreader/lib/server.js
  47. +++ b/node_modules/@subsquid/openreader/lib/server.js
  48. @@ -21,7 +21,7 @@ async function serve(options) {
  49. let { connection, subscriptionConnection, subscriptionPollInterval, maxResponseNodes, subscriptionMaxResponseNodes } = options;
  50. let dialect = options.dialect ?? 'postgres';
  51. let schema = new schema_1.SchemaBuilder(options).build();
  52. - let context = () => {
  53. + let context = ({ req }) => {
  54. let openreader = new db_1.PoolOpenreaderContext(dialect, connection, subscriptionConnection, subscriptionPollInterval);
  55. if (maxResponseNodes) {
  56. openreader.responseSizeLimit = new limit_1.ResponseSizeLimit(maxResponseNodes);
  57. @@ -31,6 +31,7 @@ async function serve(options) {
  58. openreader.subscriptionResponseSizeLimit = new limit_1.ResponseSizeLimit(subscriptionMaxResponseNodes);
  59. }
  60. return {
  61. + req,
  62. openreader
  63. };
  64. };