@solana/rpc-graphql 2.0.0-experimental.278784a → 2.0.0-experimental.5586a1b
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/index.browser.cjs +2 -40
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +2 -40
- package/dist/index.browser.js.map +1 -1
- package/dist/index.native.js +2 -36
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +2 -36
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +2 -36
- package/dist/index.node.js.map +1 -1
- package/dist/types/context.d.ts +0 -2
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/rpc.d.ts.map +1 -0
- package/package.json +4 -4
- package/dist/types/cache.d.ts +0 -7
package/dist/index.browser.cjs
CHANGED
|
@@ -4,45 +4,9 @@ var graphql = require('graphql');
|
|
|
4
4
|
|
|
5
5
|
// src/rpc.ts
|
|
6
6
|
|
|
7
|
-
// src/cache.ts
|
|
8
|
-
var stringifyValue = (value) => JSON.stringify(value, (_, value2) => {
|
|
9
|
-
if (typeof value2 === "bigint") {
|
|
10
|
-
return value2.toString() + "n";
|
|
11
|
-
}
|
|
12
|
-
return value2;
|
|
13
|
-
});
|
|
14
|
-
var parseValue = (value) => JSON.parse(value, (_, value2) => {
|
|
15
|
-
if (typeof value2 === "string" && /\d+n$/.test(value2)) {
|
|
16
|
-
return BigInt(value2.slice(0, -1));
|
|
17
|
-
}
|
|
18
|
-
return value2;
|
|
19
|
-
});
|
|
20
|
-
var cacheKey = (key, variables) => `GraphQLCache:${stringifyValue(key)}:${stringifyValue(variables)}`;
|
|
21
|
-
function createGraphQLCache() {
|
|
22
|
-
return {
|
|
23
|
-
// Browser
|
|
24
|
-
flush: () => {
|
|
25
|
-
for (let i = localStorage.length - 1; i >= 0; i--) {
|
|
26
|
-
const storageKey = localStorage.key(i);
|
|
27
|
-
if (storageKey && storageKey.startsWith("GraphQLCache:")) {
|
|
28
|
-
localStorage.removeItem(storageKey);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
get: (key, variables) => {
|
|
33
|
-
const value = localStorage.getItem(cacheKey(key, variables));
|
|
34
|
-
return value === null ? null : parseValue(value);
|
|
35
|
-
},
|
|
36
|
-
insert: (key, variables, value) => {
|
|
37
|
-
localStorage.setItem(cacheKey(key, variables), stringifyValue(value));
|
|
38
|
-
}
|
|
39
|
-
} ;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
7
|
// src/context.ts
|
|
43
8
|
function createSolanaGraphQLContext(rpc) {
|
|
44
|
-
|
|
45
|
-
return { cache, rpc };
|
|
9
|
+
return { rpc };
|
|
46
10
|
}
|
|
47
11
|
|
|
48
12
|
// src/rpc.ts
|
|
@@ -60,14 +24,12 @@ function createRpcGraphQL(rpc) {
|
|
|
60
24
|
return {
|
|
61
25
|
context,
|
|
62
26
|
async query(source, variableValues) {
|
|
63
|
-
|
|
27
|
+
return graphql.graphql({
|
|
64
28
|
contextValue: this.context,
|
|
65
29
|
schema: this.schema,
|
|
66
30
|
source,
|
|
67
31
|
variableValues
|
|
68
32
|
});
|
|
69
|
-
this.context.cache.flush();
|
|
70
|
-
return result;
|
|
71
33
|
},
|
|
72
34
|
schema
|
|
73
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/rpc.ts","../src/
|
|
1
|
+
{"version":3,"sources":["../src/rpc.ts","../src/context.ts"],"names":[],"mappings":";AAEA,SAAS,SAAS,mBAAmB,qBAA6B;;;ACK3D,SAAS,2BAA2B,KAA+C;AACtF,SAAO,EAAE,IAAI;AACjB;;;ADMO,SAAS,iBAAiB,KAAwC;AACrE,QAAM,UAAU,2BAA2B,GAAG;AAC9C,QAAM,SAAS,IAAI,cAAc;AAAA,IAC7B,OAAO,IAAI,kBAAkB;AAAA,MACzB,QAAQ;AAAA;AAAA,MAER;AAAA,MACA,MAAM;AAAA,IACV,CAAC;AAAA,IACD,OAAO,CAAC;AAAA,EACZ,CAAC;AACD,SAAO;AAAA,IACH;AAAA,IACA,MAAM,MAAM,QAAyB,gBAA2D;AAC5F,aAAO,QAAQ;AAAA,QACX,cAAc,KAAK;AAAA,QACnB,QAAQ,KAAK;AAAA,QACb;AAAA,QACA;AAAA,MACJ,CAAC;AAAA,IACL;AAAA,IACA;AAAA,EACJ;AACJ","sourcesContent":["import { SolanaRpcMethods } from '@solana/rpc-core';\nimport { Rpc } from '@solana/rpc-transport/dist/types/json-rpc-types';\nimport { graphql, GraphQLObjectType, GraphQLSchema, Source } from 'graphql';\n\nimport { createSolanaGraphQLContext, RpcGraphQLContext } from './context';\n\nexport interface RpcGraphQL {\n context: RpcGraphQLContext;\n query(\n source: string | Source,\n variableValues?: { readonly [variable: string]: unknown }\n ): ReturnType<typeof graphql>;\n schema: GraphQLSchema;\n}\n\nexport function createRpcGraphQL(rpc: Rpc<SolanaRpcMethods>): RpcGraphQL {\n const context = createSolanaGraphQLContext(rpc);\n const schema = new GraphQLSchema({\n query: new GraphQLObjectType({\n fields: {\n /** Root queries */\n },\n name: 'RootQuery',\n }),\n types: [],\n });\n return {\n context,\n async query(source: string | Source, variableValues?: { readonly [variable: string]: unknown }) {\n return graphql({\n contextValue: this.context,\n schema: this.schema,\n source,\n variableValues,\n });\n },\n schema,\n };\n}\n","import { SolanaRpcMethods } from '@solana/rpc-core';\nimport { Rpc } from '@solana/rpc-transport/dist/types/json-rpc-types';\n\nexport interface RpcGraphQLContext {\n rpc: Rpc<SolanaRpcMethods>;\n}\n\nexport function createSolanaGraphQLContext(rpc: Rpc<SolanaRpcMethods>): RpcGraphQLContext {\n return { rpc };\n}\n"]}
|
package/dist/index.browser.js
CHANGED
|
@@ -2,45 +2,9 @@ import { GraphQLSchema, GraphQLObjectType, graphql } from 'graphql';
|
|
|
2
2
|
|
|
3
3
|
// src/rpc.ts
|
|
4
4
|
|
|
5
|
-
// src/cache.ts
|
|
6
|
-
var stringifyValue = (value) => JSON.stringify(value, (_, value2) => {
|
|
7
|
-
if (typeof value2 === "bigint") {
|
|
8
|
-
return value2.toString() + "n";
|
|
9
|
-
}
|
|
10
|
-
return value2;
|
|
11
|
-
});
|
|
12
|
-
var parseValue = (value) => JSON.parse(value, (_, value2) => {
|
|
13
|
-
if (typeof value2 === "string" && /\d+n$/.test(value2)) {
|
|
14
|
-
return BigInt(value2.slice(0, -1));
|
|
15
|
-
}
|
|
16
|
-
return value2;
|
|
17
|
-
});
|
|
18
|
-
var cacheKey = (key, variables) => `GraphQLCache:${stringifyValue(key)}:${stringifyValue(variables)}`;
|
|
19
|
-
function createGraphQLCache() {
|
|
20
|
-
return {
|
|
21
|
-
// Browser
|
|
22
|
-
flush: () => {
|
|
23
|
-
for (let i = localStorage.length - 1; i >= 0; i--) {
|
|
24
|
-
const storageKey = localStorage.key(i);
|
|
25
|
-
if (storageKey && storageKey.startsWith("GraphQLCache:")) {
|
|
26
|
-
localStorage.removeItem(storageKey);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
get: (key, variables) => {
|
|
31
|
-
const value = localStorage.getItem(cacheKey(key, variables));
|
|
32
|
-
return value === null ? null : parseValue(value);
|
|
33
|
-
},
|
|
34
|
-
insert: (key, variables, value) => {
|
|
35
|
-
localStorage.setItem(cacheKey(key, variables), stringifyValue(value));
|
|
36
|
-
}
|
|
37
|
-
} ;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
5
|
// src/context.ts
|
|
41
6
|
function createSolanaGraphQLContext(rpc) {
|
|
42
|
-
|
|
43
|
-
return { cache, rpc };
|
|
7
|
+
return { rpc };
|
|
44
8
|
}
|
|
45
9
|
|
|
46
10
|
// src/rpc.ts
|
|
@@ -58,14 +22,12 @@ function createRpcGraphQL(rpc) {
|
|
|
58
22
|
return {
|
|
59
23
|
context,
|
|
60
24
|
async query(source, variableValues) {
|
|
61
|
-
|
|
25
|
+
return graphql({
|
|
62
26
|
contextValue: this.context,
|
|
63
27
|
schema: this.schema,
|
|
64
28
|
source,
|
|
65
29
|
variableValues
|
|
66
30
|
});
|
|
67
|
-
this.context.cache.flush();
|
|
68
|
-
return result;
|
|
69
31
|
},
|
|
70
32
|
schema
|
|
71
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/rpc.ts","../src/
|
|
1
|
+
{"version":3,"sources":["../src/rpc.ts","../src/context.ts"],"names":[],"mappings":";AAEA,SAAS,SAAS,mBAAmB,qBAA6B;;;ACK3D,SAAS,2BAA2B,KAA+C;AACtF,SAAO,EAAE,IAAI;AACjB;;;ADMO,SAAS,iBAAiB,KAAwC;AACrE,QAAM,UAAU,2BAA2B,GAAG;AAC9C,QAAM,SAAS,IAAI,cAAc;AAAA,IAC7B,OAAO,IAAI,kBAAkB;AAAA,MACzB,QAAQ;AAAA;AAAA,MAER;AAAA,MACA,MAAM;AAAA,IACV,CAAC;AAAA,IACD,OAAO,CAAC;AAAA,EACZ,CAAC;AACD,SAAO;AAAA,IACH;AAAA,IACA,MAAM,MAAM,QAAyB,gBAA2D;AAC5F,aAAO,QAAQ;AAAA,QACX,cAAc,KAAK;AAAA,QACnB,QAAQ,KAAK;AAAA,QACb;AAAA,QACA;AAAA,MACJ,CAAC;AAAA,IACL;AAAA,IACA;AAAA,EACJ;AACJ","sourcesContent":["import { SolanaRpcMethods } from '@solana/rpc-core';\nimport { Rpc } from '@solana/rpc-transport/dist/types/json-rpc-types';\nimport { graphql, GraphQLObjectType, GraphQLSchema, Source } from 'graphql';\n\nimport { createSolanaGraphQLContext, RpcGraphQLContext } from './context';\n\nexport interface RpcGraphQL {\n context: RpcGraphQLContext;\n query(\n source: string | Source,\n variableValues?: { readonly [variable: string]: unknown }\n ): ReturnType<typeof graphql>;\n schema: GraphQLSchema;\n}\n\nexport function createRpcGraphQL(rpc: Rpc<SolanaRpcMethods>): RpcGraphQL {\n const context = createSolanaGraphQLContext(rpc);\n const schema = new GraphQLSchema({\n query: new GraphQLObjectType({\n fields: {\n /** Root queries */\n },\n name: 'RootQuery',\n }),\n types: [],\n });\n return {\n context,\n async query(source: string | Source, variableValues?: { readonly [variable: string]: unknown }) {\n return graphql({\n contextValue: this.context,\n schema: this.schema,\n source,\n variableValues,\n });\n },\n schema,\n };\n}\n","import { SolanaRpcMethods } from '@solana/rpc-core';\nimport { Rpc } from '@solana/rpc-transport/dist/types/json-rpc-types';\n\nexport interface RpcGraphQLContext {\n rpc: Rpc<SolanaRpcMethods>;\n}\n\nexport function createSolanaGraphQLContext(rpc: Rpc<SolanaRpcMethods>): RpcGraphQLContext {\n return { rpc };\n}\n"]}
|
package/dist/index.native.js
CHANGED
|
@@ -2,41 +2,9 @@ import { GraphQLSchema, GraphQLObjectType, graphql } from 'graphql';
|
|
|
2
2
|
|
|
3
3
|
// src/rpc.ts
|
|
4
4
|
|
|
5
|
-
// src/cache.ts
|
|
6
|
-
var inMemoryCache = {};
|
|
7
|
-
var stringifyValue = (value) => JSON.stringify(value, (_, value2) => {
|
|
8
|
-
if (typeof value2 === "bigint") {
|
|
9
|
-
return value2.toString() + "n";
|
|
10
|
-
}
|
|
11
|
-
return value2;
|
|
12
|
-
});
|
|
13
|
-
var parseValue = (value) => JSON.parse(value, (_, value2) => {
|
|
14
|
-
if (typeof value2 === "string" && /\d+n$/.test(value2)) {
|
|
15
|
-
return BigInt(value2.slice(0, -1));
|
|
16
|
-
}
|
|
17
|
-
return value2;
|
|
18
|
-
});
|
|
19
|
-
var cacheKey = (key, variables) => `GraphQLCache:${stringifyValue(key)}:${stringifyValue(variables)}`;
|
|
20
|
-
function createGraphQLCache() {
|
|
21
|
-
return {
|
|
22
|
-
// Node.js
|
|
23
|
-
flush: () => {
|
|
24
|
-
Object.keys(inMemoryCache).forEach((key) => delete inMemoryCache[key]);
|
|
25
|
-
},
|
|
26
|
-
get: (key, variables) => {
|
|
27
|
-
const value = inMemoryCache[cacheKey(key, variables)];
|
|
28
|
-
return value === void 0 ? null : parseValue(value);
|
|
29
|
-
},
|
|
30
|
-
insert: (key, variables, value) => {
|
|
31
|
-
inMemoryCache[cacheKey(key, variables)] = stringifyValue(value);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
5
|
// src/context.ts
|
|
37
6
|
function createSolanaGraphQLContext(rpc) {
|
|
38
|
-
|
|
39
|
-
return { cache, rpc };
|
|
7
|
+
return { rpc };
|
|
40
8
|
}
|
|
41
9
|
|
|
42
10
|
// src/rpc.ts
|
|
@@ -54,14 +22,12 @@ function createRpcGraphQL(rpc) {
|
|
|
54
22
|
return {
|
|
55
23
|
context,
|
|
56
24
|
async query(source, variableValues) {
|
|
57
|
-
|
|
25
|
+
return graphql({
|
|
58
26
|
contextValue: this.context,
|
|
59
27
|
schema: this.schema,
|
|
60
28
|
source,
|
|
61
29
|
variableValues
|
|
62
30
|
});
|
|
63
|
-
this.context.cache.flush();
|
|
64
|
-
return result;
|
|
65
31
|
},
|
|
66
32
|
schema
|
|
67
33
|
};
|
package/dist/index.native.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/rpc.ts","../src/
|
|
1
|
+
{"version":3,"sources":["../src/rpc.ts","../src/context.ts"],"names":[],"mappings":";AAEA,SAAS,SAAS,mBAAmB,qBAA6B;;;ACK3D,SAAS,2BAA2B,KAA+C;AACtF,SAAO,EAAE,IAAI;AACjB;;;ADMO,SAAS,iBAAiB,KAAwC;AACrE,QAAM,UAAU,2BAA2B,GAAG;AAC9C,QAAM,SAAS,IAAI,cAAc;AAAA,IAC7B,OAAO,IAAI,kBAAkB;AAAA,MACzB,QAAQ;AAAA;AAAA,MAER;AAAA,MACA,MAAM;AAAA,IACV,CAAC;AAAA,IACD,OAAO,CAAC;AAAA,EACZ,CAAC;AACD,SAAO;AAAA,IACH;AAAA,IACA,MAAM,MAAM,QAAyB,gBAA2D;AAC5F,aAAO,QAAQ;AAAA,QACX,cAAc,KAAK;AAAA,QACnB,QAAQ,KAAK;AAAA,QACb;AAAA,QACA;AAAA,MACJ,CAAC;AAAA,IACL;AAAA,IACA;AAAA,EACJ;AACJ","sourcesContent":["import { SolanaRpcMethods } from '@solana/rpc-core';\nimport { Rpc } from '@solana/rpc-transport/dist/types/json-rpc-types';\nimport { graphql, GraphQLObjectType, GraphQLSchema, Source } from 'graphql';\n\nimport { createSolanaGraphQLContext, RpcGraphQLContext } from './context';\n\nexport interface RpcGraphQL {\n context: RpcGraphQLContext;\n query(\n source: string | Source,\n variableValues?: { readonly [variable: string]: unknown }\n ): ReturnType<typeof graphql>;\n schema: GraphQLSchema;\n}\n\nexport function createRpcGraphQL(rpc: Rpc<SolanaRpcMethods>): RpcGraphQL {\n const context = createSolanaGraphQLContext(rpc);\n const schema = new GraphQLSchema({\n query: new GraphQLObjectType({\n fields: {\n /** Root queries */\n },\n name: 'RootQuery',\n }),\n types: [],\n });\n return {\n context,\n async query(source: string | Source, variableValues?: { readonly [variable: string]: unknown }) {\n return graphql({\n contextValue: this.context,\n schema: this.schema,\n source,\n variableValues,\n });\n },\n schema,\n };\n}\n","import { SolanaRpcMethods } from '@solana/rpc-core';\nimport { Rpc } from '@solana/rpc-transport/dist/types/json-rpc-types';\n\nexport interface RpcGraphQLContext {\n rpc: Rpc<SolanaRpcMethods>;\n}\n\nexport function createSolanaGraphQLContext(rpc: Rpc<SolanaRpcMethods>): RpcGraphQLContext {\n return { rpc };\n}\n"]}
|
package/dist/index.node.cjs
CHANGED
|
@@ -4,41 +4,9 @@ var graphql = require('graphql');
|
|
|
4
4
|
|
|
5
5
|
// src/rpc.ts
|
|
6
6
|
|
|
7
|
-
// src/cache.ts
|
|
8
|
-
var inMemoryCache = {};
|
|
9
|
-
var stringifyValue = (value) => JSON.stringify(value, (_, value2) => {
|
|
10
|
-
if (typeof value2 === "bigint") {
|
|
11
|
-
return value2.toString() + "n";
|
|
12
|
-
}
|
|
13
|
-
return value2;
|
|
14
|
-
});
|
|
15
|
-
var parseValue = (value) => JSON.parse(value, (_, value2) => {
|
|
16
|
-
if (typeof value2 === "string" && /\d+n$/.test(value2)) {
|
|
17
|
-
return BigInt(value2.slice(0, -1));
|
|
18
|
-
}
|
|
19
|
-
return value2;
|
|
20
|
-
});
|
|
21
|
-
var cacheKey = (key, variables) => `GraphQLCache:${stringifyValue(key)}:${stringifyValue(variables)}`;
|
|
22
|
-
function createGraphQLCache() {
|
|
23
|
-
return {
|
|
24
|
-
// Node.js
|
|
25
|
-
flush: () => {
|
|
26
|
-
Object.keys(inMemoryCache).forEach((key) => delete inMemoryCache[key]);
|
|
27
|
-
},
|
|
28
|
-
get: (key, variables) => {
|
|
29
|
-
const value = inMemoryCache[cacheKey(key, variables)];
|
|
30
|
-
return value === void 0 ? null : parseValue(value);
|
|
31
|
-
},
|
|
32
|
-
insert: (key, variables, value) => {
|
|
33
|
-
inMemoryCache[cacheKey(key, variables)] = stringifyValue(value);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
7
|
// src/context.ts
|
|
39
8
|
function createSolanaGraphQLContext(rpc) {
|
|
40
|
-
|
|
41
|
-
return { cache, rpc };
|
|
9
|
+
return { rpc };
|
|
42
10
|
}
|
|
43
11
|
|
|
44
12
|
// src/rpc.ts
|
|
@@ -56,14 +24,12 @@ function createRpcGraphQL(rpc) {
|
|
|
56
24
|
return {
|
|
57
25
|
context,
|
|
58
26
|
async query(source, variableValues) {
|
|
59
|
-
|
|
27
|
+
return graphql.graphql({
|
|
60
28
|
contextValue: this.context,
|
|
61
29
|
schema: this.schema,
|
|
62
30
|
source,
|
|
63
31
|
variableValues
|
|
64
32
|
});
|
|
65
|
-
this.context.cache.flush();
|
|
66
|
-
return result;
|
|
67
33
|
},
|
|
68
34
|
schema
|
|
69
35
|
};
|
package/dist/index.node.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/rpc.ts","../src/
|
|
1
|
+
{"version":3,"sources":["../src/rpc.ts","../src/context.ts"],"names":[],"mappings":";AAEA,SAAS,SAAS,mBAAmB,qBAA6B;;;ACK3D,SAAS,2BAA2B,KAA+C;AACtF,SAAO,EAAE,IAAI;AACjB;;;ADMO,SAAS,iBAAiB,KAAwC;AACrE,QAAM,UAAU,2BAA2B,GAAG;AAC9C,QAAM,SAAS,IAAI,cAAc;AAAA,IAC7B,OAAO,IAAI,kBAAkB;AAAA,MACzB,QAAQ;AAAA;AAAA,MAER;AAAA,MACA,MAAM;AAAA,IACV,CAAC;AAAA,IACD,OAAO,CAAC;AAAA,EACZ,CAAC;AACD,SAAO;AAAA,IACH;AAAA,IACA,MAAM,MAAM,QAAyB,gBAA2D;AAC5F,aAAO,QAAQ;AAAA,QACX,cAAc,KAAK;AAAA,QACnB,QAAQ,KAAK;AAAA,QACb;AAAA,QACA;AAAA,MACJ,CAAC;AAAA,IACL;AAAA,IACA;AAAA,EACJ;AACJ","sourcesContent":["import { SolanaRpcMethods } from '@solana/rpc-core';\nimport { Rpc } from '@solana/rpc-transport/dist/types/json-rpc-types';\nimport { graphql, GraphQLObjectType, GraphQLSchema, Source } from 'graphql';\n\nimport { createSolanaGraphQLContext, RpcGraphQLContext } from './context';\n\nexport interface RpcGraphQL {\n context: RpcGraphQLContext;\n query(\n source: string | Source,\n variableValues?: { readonly [variable: string]: unknown }\n ): ReturnType<typeof graphql>;\n schema: GraphQLSchema;\n}\n\nexport function createRpcGraphQL(rpc: Rpc<SolanaRpcMethods>): RpcGraphQL {\n const context = createSolanaGraphQLContext(rpc);\n const schema = new GraphQLSchema({\n query: new GraphQLObjectType({\n fields: {\n /** Root queries */\n },\n name: 'RootQuery',\n }),\n types: [],\n });\n return {\n context,\n async query(source: string | Source, variableValues?: { readonly [variable: string]: unknown }) {\n return graphql({\n contextValue: this.context,\n schema: this.schema,\n source,\n variableValues,\n });\n },\n schema,\n };\n}\n","import { SolanaRpcMethods } from '@solana/rpc-core';\nimport { Rpc } from '@solana/rpc-transport/dist/types/json-rpc-types';\n\nexport interface RpcGraphQLContext {\n rpc: Rpc<SolanaRpcMethods>;\n}\n\nexport function createSolanaGraphQLContext(rpc: Rpc<SolanaRpcMethods>): RpcGraphQLContext {\n return { rpc };\n}\n"]}
|
package/dist/index.node.js
CHANGED
|
@@ -2,41 +2,9 @@ import { GraphQLSchema, GraphQLObjectType, graphql } from 'graphql';
|
|
|
2
2
|
|
|
3
3
|
// src/rpc.ts
|
|
4
4
|
|
|
5
|
-
// src/cache.ts
|
|
6
|
-
var inMemoryCache = {};
|
|
7
|
-
var stringifyValue = (value) => JSON.stringify(value, (_, value2) => {
|
|
8
|
-
if (typeof value2 === "bigint") {
|
|
9
|
-
return value2.toString() + "n";
|
|
10
|
-
}
|
|
11
|
-
return value2;
|
|
12
|
-
});
|
|
13
|
-
var parseValue = (value) => JSON.parse(value, (_, value2) => {
|
|
14
|
-
if (typeof value2 === "string" && /\d+n$/.test(value2)) {
|
|
15
|
-
return BigInt(value2.slice(0, -1));
|
|
16
|
-
}
|
|
17
|
-
return value2;
|
|
18
|
-
});
|
|
19
|
-
var cacheKey = (key, variables) => `GraphQLCache:${stringifyValue(key)}:${stringifyValue(variables)}`;
|
|
20
|
-
function createGraphQLCache() {
|
|
21
|
-
return {
|
|
22
|
-
// Node.js
|
|
23
|
-
flush: () => {
|
|
24
|
-
Object.keys(inMemoryCache).forEach((key) => delete inMemoryCache[key]);
|
|
25
|
-
},
|
|
26
|
-
get: (key, variables) => {
|
|
27
|
-
const value = inMemoryCache[cacheKey(key, variables)];
|
|
28
|
-
return value === void 0 ? null : parseValue(value);
|
|
29
|
-
},
|
|
30
|
-
insert: (key, variables, value) => {
|
|
31
|
-
inMemoryCache[cacheKey(key, variables)] = stringifyValue(value);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
5
|
// src/context.ts
|
|
37
6
|
function createSolanaGraphQLContext(rpc) {
|
|
38
|
-
|
|
39
|
-
return { cache, rpc };
|
|
7
|
+
return { rpc };
|
|
40
8
|
}
|
|
41
9
|
|
|
42
10
|
// src/rpc.ts
|
|
@@ -54,14 +22,12 @@ function createRpcGraphQL(rpc) {
|
|
|
54
22
|
return {
|
|
55
23
|
context,
|
|
56
24
|
async query(source, variableValues) {
|
|
57
|
-
|
|
25
|
+
return graphql({
|
|
58
26
|
contextValue: this.context,
|
|
59
27
|
schema: this.schema,
|
|
60
28
|
source,
|
|
61
29
|
variableValues
|
|
62
30
|
});
|
|
63
|
-
this.context.cache.flush();
|
|
64
|
-
return result;
|
|
65
31
|
},
|
|
66
32
|
schema
|
|
67
33
|
};
|
package/dist/index.node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/rpc.ts","../src/
|
|
1
|
+
{"version":3,"sources":["../src/rpc.ts","../src/context.ts"],"names":[],"mappings":";AAEA,SAAS,SAAS,mBAAmB,qBAA6B;;;ACK3D,SAAS,2BAA2B,KAA+C;AACtF,SAAO,EAAE,IAAI;AACjB;;;ADMO,SAAS,iBAAiB,KAAwC;AACrE,QAAM,UAAU,2BAA2B,GAAG;AAC9C,QAAM,SAAS,IAAI,cAAc;AAAA,IAC7B,OAAO,IAAI,kBAAkB;AAAA,MACzB,QAAQ;AAAA;AAAA,MAER;AAAA,MACA,MAAM;AAAA,IACV,CAAC;AAAA,IACD,OAAO,CAAC;AAAA,EACZ,CAAC;AACD,SAAO;AAAA,IACH;AAAA,IACA,MAAM,MAAM,QAAyB,gBAA2D;AAC5F,aAAO,QAAQ;AAAA,QACX,cAAc,KAAK;AAAA,QACnB,QAAQ,KAAK;AAAA,QACb;AAAA,QACA;AAAA,MACJ,CAAC;AAAA,IACL;AAAA,IACA;AAAA,EACJ;AACJ","sourcesContent":["import { SolanaRpcMethods } from '@solana/rpc-core';\nimport { Rpc } from '@solana/rpc-transport/dist/types/json-rpc-types';\nimport { graphql, GraphQLObjectType, GraphQLSchema, Source } from 'graphql';\n\nimport { createSolanaGraphQLContext, RpcGraphQLContext } from './context';\n\nexport interface RpcGraphQL {\n context: RpcGraphQLContext;\n query(\n source: string | Source,\n variableValues?: { readonly [variable: string]: unknown }\n ): ReturnType<typeof graphql>;\n schema: GraphQLSchema;\n}\n\nexport function createRpcGraphQL(rpc: Rpc<SolanaRpcMethods>): RpcGraphQL {\n const context = createSolanaGraphQLContext(rpc);\n const schema = new GraphQLSchema({\n query: new GraphQLObjectType({\n fields: {\n /** Root queries */\n },\n name: 'RootQuery',\n }),\n types: [],\n });\n return {\n context,\n async query(source: string | Source, variableValues?: { readonly [variable: string]: unknown }) {\n return graphql({\n contextValue: this.context,\n schema: this.schema,\n source,\n variableValues,\n });\n },\n schema,\n };\n}\n","import { SolanaRpcMethods } from '@solana/rpc-core';\nimport { Rpc } from '@solana/rpc-transport/dist/types/json-rpc-types';\n\nexport interface RpcGraphQLContext {\n rpc: Rpc<SolanaRpcMethods>;\n}\n\nexport function createSolanaGraphQLContext(rpc: Rpc<SolanaRpcMethods>): RpcGraphQLContext {\n return { rpc };\n}\n"]}
|
package/dist/types/context.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { SolanaRpcMethods } from '@solana/rpc-core';
|
|
2
2
|
import { Rpc } from '@solana/rpc-transport/dist/types/json-rpc-types';
|
|
3
|
-
import { GraphQLCache } from './cache';
|
|
4
3
|
export interface RpcGraphQLContext {
|
|
5
|
-
cache: GraphQLCache;
|
|
6
4
|
rpc: Rpc<SolanaRpcMethods>;
|
|
7
5
|
}
|
|
8
6
|
export declare function createSolanaGraphQLContext(rpc: Rpc<SolanaRpcMethods>): RpcGraphQLContext;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,iDAAiD,CAAC;AAEtE,MAAM,WAAW,iBAAiB;IAC9B,GAAG,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;CAC9B;AAED,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,GAAG,CAAC,gBAAgB,CAAC,GAAG,iBAAiB,CAExF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc.d.ts","sourceRoot":"","sources":["../../src/rpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,iDAAiD,CAAC;AACtE,OAAO,EAAE,OAAO,EAAqB,aAAa,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAE5E,OAAO,EAA8B,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE1E,MAAM,WAAW,UAAU;IACvB,OAAO,EAAE,iBAAiB,CAAC;IAC3B,KAAK,CACD,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,cAAc,CAAC,EAAE;QAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GAC1D,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;IAC9B,MAAM,EAAE,aAAa,CAAC;CACzB;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,CAAC,gBAAgB,CAAC,GAAG,UAAU,CAuBvE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana/rpc-graphql",
|
|
3
|
-
"version": "2.0.0-experimental.
|
|
3
|
+
"version": "2.0.0-experimental.5586a1b",
|
|
4
4
|
"description": "A library for resolving GraphQl query calls to the Solana JSON RPC API",
|
|
5
5
|
"exports": {
|
|
6
6
|
"browser": {
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
"tsup": "7.2.0",
|
|
68
68
|
"typescript": "^5.1.6",
|
|
69
69
|
"version-from-git": "^1.1.1",
|
|
70
|
-
"@solana/addresses": "2.0.0-experimental.
|
|
71
|
-
"@solana/rpc-core": "2.0.0-experimental.
|
|
72
|
-
"@solana/rpc-transport": "2.0.0-experimental.
|
|
70
|
+
"@solana/addresses": "2.0.0-experimental.5586a1b",
|
|
71
|
+
"@solana/rpc-core": "2.0.0-experimental.5586a1b",
|
|
72
|
+
"@solana/rpc-transport": "2.0.0-experimental.5586a1b",
|
|
73
73
|
"build-scripts": "0.0.0",
|
|
74
74
|
"test-config": "0.0.0",
|
|
75
75
|
"tsconfig": "0.0.0"
|
package/dist/types/cache.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export interface GraphQLCache {
|
|
2
|
-
flush(): void;
|
|
3
|
-
get(key: string | bigint, variables: unknown): unknown | null;
|
|
4
|
-
insert(key: string | bigint, variables: unknown, value: unknown): void;
|
|
5
|
-
}
|
|
6
|
-
export declare function createGraphQLCache(): GraphQLCache;
|
|
7
|
-
//# sourceMappingURL=cache.d.ts.map
|