@solana/rpc-graphql 6.3.1 → 6.3.2-canary-20260313112147
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/package.json +5 -4
- package/src/context.ts +47 -0
- package/src/index.ts +65 -0
- package/src/loaders/__tests__/account-loader-test.ts +1537 -0
- package/src/loaders/__tests__/block-loader-test.ts +485 -0
- package/src/loaders/__tests__/program-accounts-loader-test.ts +622 -0
- package/src/loaders/__tests__/transaction-loader-test.ts +488 -0
- package/src/loaders/account.ts +188 -0
- package/src/loaders/block.ts +82 -0
- package/src/loaders/coalescer.ts +241 -0
- package/src/loaders/index.ts +5 -0
- package/src/loaders/loader.ts +99 -0
- package/src/loaders/program-accounts.ts +91 -0
- package/src/loaders/transaction.ts +87 -0
- package/src/resolvers/__tests__/account-resolver-test.ts +410 -0
- package/src/resolvers/__tests__/block-inputs-test.ts +141 -0
- package/src/resolvers/__tests__/block-resolver-test.ts +179 -0
- package/src/resolvers/__tests__/program-accounts-resolver-test.ts +223 -0
- package/src/resolvers/__tests__/transaction-resolver-test.ts +159 -0
- package/src/resolvers/account.ts +149 -0
- package/src/resolvers/block.ts +123 -0
- package/src/resolvers/program-accounts.ts +115 -0
- package/src/resolvers/resolve-info/account.ts +141 -0
- package/src/resolvers/resolve-info/block.ts +57 -0
- package/src/resolvers/resolve-info/index.ts +5 -0
- package/src/resolvers/resolve-info/program-accounts.ts +35 -0
- package/src/resolvers/resolve-info/transaction.ts +101 -0
- package/src/resolvers/resolve-info/visitor.ts +86 -0
- package/src/resolvers/transaction.ts +165 -0
- package/src/schema/type-defs/account.ts +564 -0
- package/src/schema/type-defs/block.ts +15 -0
- package/src/schema/type-defs/index.ts +15 -0
- package/src/schema/type-defs/instruction.ts +1646 -0
- package/src/schema/type-defs/root.ts +18 -0
- package/src/schema/type-defs/transaction.ts +75 -0
- package/src/schema/type-defs/types.ts +125 -0
- package/src/schema/type-resolvers/account.ts +314 -0
- package/src/schema/type-resolvers/block.ts +8 -0
- package/src/schema/type-resolvers/index.ts +24 -0
- package/src/schema/type-resolvers/instruction.ts +1198 -0
- package/src/schema/type-resolvers/root.ts +15 -0
- package/src/schema/type-resolvers/transaction.ts +7 -0
- package/src/schema/type-resolvers/types.ts +104 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana/rpc-graphql",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.2-canary-20260313112147",
|
|
4
4
|
"description": "A library for resolving GraphQl query calls to the Solana JSON RPC API",
|
|
5
5
|
"homepage": "https://www.solanakit.com/api#solanarpc-graphql",
|
|
6
6
|
"exports": {
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
"types": "./dist/types/index.d.ts",
|
|
34
34
|
"type": "commonjs",
|
|
35
35
|
"files": [
|
|
36
|
-
"./dist/"
|
|
36
|
+
"./dist/",
|
|
37
|
+
"./src/"
|
|
37
38
|
],
|
|
38
39
|
"sideEffects": false,
|
|
39
40
|
"keywords": [
|
|
@@ -58,8 +59,8 @@
|
|
|
58
59
|
"@graphql-tools/schema": "^10.0.31",
|
|
59
60
|
"dataloader": "^2.2.3",
|
|
60
61
|
"graphql": "^16.13.1",
|
|
61
|
-
"@solana/
|
|
62
|
-
"@solana/
|
|
62
|
+
"@solana/fast-stable-stringify": "6.3.2-canary-20260313112147",
|
|
63
|
+
"@solana/codecs-strings": "6.3.2-canary-20260313112147"
|
|
63
64
|
},
|
|
64
65
|
"peerDependencies": {
|
|
65
66
|
"typescript": "^5.0.0"
|
package/src/context.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
GetAccountInfoApi,
|
|
3
|
+
GetBlockApi,
|
|
4
|
+
GetMultipleAccountsApi,
|
|
5
|
+
GetProgramAccountsApi,
|
|
6
|
+
GetTransactionApi,
|
|
7
|
+
Rpc,
|
|
8
|
+
} from '@solana/rpc';
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
createAccountLoader,
|
|
12
|
+
createBlockLoader,
|
|
13
|
+
createProgramAccountsLoader,
|
|
14
|
+
createTransactionLoader,
|
|
15
|
+
RpcGraphQLLoaders,
|
|
16
|
+
} from './loaders';
|
|
17
|
+
|
|
18
|
+
type Config = {
|
|
19
|
+
/**
|
|
20
|
+
* Maximum number of acceptable bytes to waste before splitting two
|
|
21
|
+
* `dataSlice` requests into two requests.
|
|
22
|
+
*/
|
|
23
|
+
maxDataSliceByteRange: number;
|
|
24
|
+
/**
|
|
25
|
+
* Maximum number of accounts to fetch in a single batch.
|
|
26
|
+
* See https://docs.solana.com/api/http#getmultipleaccounts.
|
|
27
|
+
*/
|
|
28
|
+
maxMultipleAccountsBatchSize: number;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export interface RpcGraphQLContext {
|
|
32
|
+
loaders: RpcGraphQLLoaders;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function createSolanaGraphQLContext(
|
|
36
|
+
rpc: Rpc<GetAccountInfoApi & GetBlockApi & GetMultipleAccountsApi & GetProgramAccountsApi & GetTransactionApi>,
|
|
37
|
+
config: Config,
|
|
38
|
+
): RpcGraphQLContext {
|
|
39
|
+
return {
|
|
40
|
+
loaders: {
|
|
41
|
+
account: createAccountLoader(rpc, config),
|
|
42
|
+
block: createBlockLoader(rpc),
|
|
43
|
+
programAccounts: createProgramAccountsLoader(rpc, config),
|
|
44
|
+
transaction: createTransactionLoader(rpc),
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { makeExecutableSchema } from '@graphql-tools/schema';
|
|
2
|
+
import { graphql } from 'graphql';
|
|
3
|
+
|
|
4
|
+
import { createSolanaGraphQLContext } from './context';
|
|
5
|
+
import { createSolanaGraphQLTypeDefs } from './schema/type-defs';
|
|
6
|
+
import { createSolanaGraphQLTypeResolvers } from './schema/type-resolvers';
|
|
7
|
+
|
|
8
|
+
export interface RpcGraphQL {
|
|
9
|
+
query(
|
|
10
|
+
source: Parameters<typeof graphql>[0]['source'],
|
|
11
|
+
variableValues?: Parameters<typeof graphql>[0]['variableValues'],
|
|
12
|
+
): ReturnType<typeof graphql>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Create a GraphQL RPC client resolver.
|
|
17
|
+
*
|
|
18
|
+
* @param rpc Solana RPC client.
|
|
19
|
+
* @param schema GraphQL schema.
|
|
20
|
+
* @param config Optional GraphQL resolver configurations.
|
|
21
|
+
* @returns GraphQL RPC client resolver.
|
|
22
|
+
*/
|
|
23
|
+
export function createRpcGraphQL(
|
|
24
|
+
rpc: Parameters<typeof createSolanaGraphQLContext>[0],
|
|
25
|
+
schema: ReturnType<typeof makeExecutableSchema>,
|
|
26
|
+
config?: Partial<Parameters<typeof createSolanaGraphQLContext>[1]>,
|
|
27
|
+
): RpcGraphQL {
|
|
28
|
+
const rpcGraphQLConfig = {
|
|
29
|
+
maxDataSliceByteRange: config?.maxDataSliceByteRange ?? 200,
|
|
30
|
+
maxMultipleAccountsBatchSize: config?.maxMultipleAccountsBatchSize ?? 100,
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
async query(source, variableValues?) {
|
|
34
|
+
const contextValue = createSolanaGraphQLContext(rpc, rpcGraphQLConfig);
|
|
35
|
+
return await graphql({
|
|
36
|
+
contextValue,
|
|
37
|
+
schema,
|
|
38
|
+
source,
|
|
39
|
+
variableValues,
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Create a Solana GraphQL RPC client resolver.
|
|
47
|
+
*
|
|
48
|
+
* Configures the client resolver to use the default Solana GraphQL schema.
|
|
49
|
+
*
|
|
50
|
+
* @param rpc Solana RPC client.
|
|
51
|
+
* @param config Optional GraphQL resolver configurations.
|
|
52
|
+
* @returns Solana GraphQL RPC client resolver.
|
|
53
|
+
*/
|
|
54
|
+
export function createSolanaRpcGraphQL(
|
|
55
|
+
rpc: Parameters<typeof createSolanaGraphQLContext>[0],
|
|
56
|
+
config?: Partial<Parameters<typeof createSolanaGraphQLContext>[1]>,
|
|
57
|
+
): RpcGraphQL {
|
|
58
|
+
const schema = makeExecutableSchema({
|
|
59
|
+
resolvers: createSolanaGraphQLTypeResolvers(),
|
|
60
|
+
typeDefs: createSolanaGraphQLTypeDefs(),
|
|
61
|
+
});
|
|
62
|
+
return createRpcGraphQL(rpc, schema, config);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { createSolanaGraphQLTypeDefs, createSolanaGraphQLTypeResolvers };
|