Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(experimental): graphql: slot-based nested queries #2643

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 60 additions & 20 deletions packages/rpc-graphql/src/__tests__/account-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,12 @@ describe('account', () => {
authority {
address
}
deactivationSlot
lastExtendedSlot
deactivationSlot {
slot
}
lastExtendedSlot {
slot
}
lastExtendedSlotStartIndex
}
}
Expand All @@ -583,9 +587,13 @@ describe('account', () => {
authority: {
address: '4msgK65vdz5ADUAB3eTQGpF388NuQUAoknLxutUQJd5B',
},
deactivationSlot: expect.any(BigInt),
deactivationSlot: {
slot: expect.any(BigInt),
},
lamports: expect.any(BigInt),
lastExtendedSlot: expect.any(BigInt),
lastExtendedSlot: {
slot: expect.any(BigInt),
},
lastExtendedSlotStartIndex: expect.any(Number),
ownerProgram: {
address: 'AddressLookupTab1e1111111111111111111111111',
Expand Down Expand Up @@ -836,17 +844,23 @@ describe('account', () => {
previousCredits
}
lastTimestamp {
slot
slot {
slot
}
timestamp
}
node {
address
}
priorVoters
rootSlot
rootSlot {
slot
}
votes {
confirmationCount
slot
slot {
slot
}
}
}
}
Expand Down Expand Up @@ -878,7 +892,9 @@ describe('account', () => {
]),
lamports: expect.any(BigInt),
lastTimestamp: {
slot: expect.any(BigInt),
slot: {
slot: expect.any(BigInt),
},
timestamp: expect.any(BigInt),
},
node: {
Expand All @@ -889,12 +905,16 @@ describe('account', () => {
},
priorVoters: expect.any(Array),
rentEpoch: expect.any(BigInt),
rootSlot: expect.any(BigInt),
rootSlot: {
slot: expect.any(BigInt),
},
space: 3762n,
votes: expect.arrayContaining([
{
confirmationCount: expect.any(Number),
slot: expect.any(BigInt),
slot: {
slot: expect.any(BigInt),
},
},
]),
},
Expand All @@ -921,7 +941,9 @@ describe('account', () => {
epoch
epochStartTimestamp
leaderScheduleEpoch
slot
slot {
slot
}
unixTimestamp
}
}
Expand All @@ -940,7 +962,9 @@ describe('account', () => {
address: 'Sysvar1111111111111111111111111111111111111',
},
rentEpoch: expect.any(BigInt),
slot: expect.any(BigInt),
slot: {
slot: expect.any(BigInt),
},
space: expect.any(BigInt),
unixTimestamp: expect.any(BigInt),
},
Expand All @@ -966,7 +990,9 @@ describe('account', () => {
space
... on SysvarEpochScheduleAccount {
firstNormalEpoch
firstNormalSlot
firstNormalSlot {
slot
}
leaderScheduleSlotOffset
slotsPerEpoch
warmup
Expand All @@ -980,7 +1006,9 @@ describe('account', () => {
account: {
address: 'SysvarEpochSchedu1e111111111111111111111111',
firstNormalEpoch: expect.any(BigInt),
firstNormalSlot: expect.any(BigInt),
firstNormalSlot: {
slot: expect.any(BigInt),
},
lamports: expect.any(BigInt),
leaderScheduleSlotOffset: expect.any(BigInt),
ownerProgram: {
Expand Down Expand Up @@ -1051,7 +1079,9 @@ describe('account', () => {
rentEpoch
space
... on SysvarLastRestartSlotAccount {
lastRestartSlot
lastRestartSlot {
slot
}
}
}
}
Expand All @@ -1062,7 +1092,9 @@ describe('account', () => {
account: {
address: 'SysvarLastRestartS1ot1111111111111111111111',
lamports: expect.any(BigInt),
lastRestartSlot: expect.any(BigInt),
lastRestartSlot: {
slot: expect.any(BigInt),
},
ownerProgram: {
address: 'Sysvar1111111111111111111111111111111111111',
},
Expand Down Expand Up @@ -1180,7 +1212,9 @@ describe('account', () => {
... on SysvarSlotHashesAccount {
entries {
hash
slot
slot {
slot
}
}
}
}
Expand All @@ -1194,7 +1228,9 @@ describe('account', () => {
entries: expect.arrayContaining([
{
hash: expect.any(String),
slot: expect.any(BigInt),
slot: {
slot: expect.any(BigInt),
},
},
]),
lamports: expect.any(BigInt),
Expand Down Expand Up @@ -1224,7 +1260,9 @@ describe('account', () => {
space
... on SysvarSlotHistoryAccount {
bits
nextSlot
nextSlot {
slot
}
}
}
}
Expand All @@ -1236,7 +1274,9 @@ describe('account', () => {
address: 'SysvarS1otHistory11111111111111111111111111',
bits: expect.any(String),
lamports: expect.any(BigInt),
nextSlot: expect.any(BigInt),
nextSlot: {
slot: expect.any(BigInt),
},
ownerProgram: {
address: 'Sysvar1111111111111111111111111111111111111',
},
Expand Down
8 changes: 6 additions & 2 deletions packages/rpc-graphql/src/__tests__/block-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ describe('block', () => {
query testQuery($slot: Slot!) {
block(slot: $slot) {
blockhash
parentSlot
parentSlot {
slot
}
rewards {
pubkey
lamports
Expand All @@ -81,7 +83,9 @@ describe('block', () => {
data: {
block: {
blockhash: expect.any(String),
parentSlot: expect.any(BigInt),
parentSlot: {
slot: expect.any(BigInt),
},
rewards: expect.arrayContaining([
{
lamports: expect.any(BigInt),
Expand Down
40 changes: 30 additions & 10 deletions packages/rpc-graphql/src/__tests__/program-accounts-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,12 @@ describe('programAccounts', () => {
authority {
address
}
deactivationSlot
lastExtendedSlot
deactivationSlot {
slot
}
lastExtendedSlot {
slot
}
lastExtendedSlotStartIndex
}
}
Expand All @@ -212,9 +216,13 @@ describe('programAccounts', () => {
authority: {
address: expect.any(String),
},
deactivationSlot: expect.any(BigInt),
deactivationSlot: {
slot: expect.any(BigInt),
},
lamports: expect.any(BigInt),
lastExtendedSlot: expect.any(BigInt),
lastExtendedSlot: {
slot: expect.any(BigInt),
},
lastExtendedSlotStartIndex: expect.any(Number),
ownerProgram: {
address: 'AddressLookupTab1e1111111111111111111111111',
Expand Down Expand Up @@ -475,17 +483,23 @@ describe('programAccounts', () => {
previousCredits
}
lastTimestamp {
slot
slot {
slot
}
timestamp
}
node {
address
}
priorVoters
rootSlot
rootSlot {
slot
}
votes {
confirmationCount
slot
slot {
slot
}
}
}
}
Expand Down Expand Up @@ -518,7 +532,9 @@ describe('programAccounts', () => {
]),
lamports: expect.any(BigInt),
lastTimestamp: {
slot: expect.any(BigInt),
slot: {
slot: expect.any(BigInt),
},
timestamp: expect.any(BigInt),
},
node: {
Expand All @@ -528,11 +544,15 @@ describe('programAccounts', () => {
address: 'Vote111111111111111111111111111111111111111',
},
priorVoters: expect.any(Array),
rootSlot: expect.any(BigInt),
rootSlot: {
slot: expect.any(BigInt),
},
votes: expect.arrayContaining([
{
confirmationCount: expect.any(Number),
slot: expect.any(BigInt),
slot: {
slot: expect.any(BigInt),
},
},
]),
},
Expand Down
8 changes: 6 additions & 2 deletions packages/rpc-graphql/src/__tests__/transaction-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ describe('transaction', () => {
query testQuery($signature: Signature!) {
transaction(signature: $signature) {
blockTime
slot
slot {
slot
}
}
}
`;
Expand All @@ -68,7 +70,9 @@ describe('transaction', () => {
data: {
transaction: {
blockTime: expect.any(BigInt),
slot: expect.any(BigInt),
slot: {
slot: expect.any(BigInt),
},
},
},
});
Expand Down
6 changes: 3 additions & 3 deletions packages/rpc-graphql/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { makeExecutableSchema } from '@graphql-tools/schema';
import { graphql } from 'graphql';

import { createSolanaGraphQLContext } from './context';
import { createSolanaGraphQLResolvers } from './resolvers';
import { createSolanaGraphQLTypeDefs } from './schema';
import { createSolanaGraphQLTypeDefs } from './schema/type-defs';
import { createSolanaGraphQLTypeResolvers } from './schema/type-resolvers';

export interface RpcGraphQL {
query(
Expand All @@ -21,7 +21,7 @@ export function createRpcGraphQL(
maxMultipleAccountsBatchSize: config?.maxMultipleAccountsBatchSize ?? 100,
};
const schema = makeExecutableSchema({
resolvers: createSolanaGraphQLResolvers(),
resolvers: createSolanaGraphQLTypeResolvers(),
typeDefs: createSolanaGraphQLTypeDefs(),
});
return {
Expand Down
Loading
Loading