Skip to content

Commit

Permalink
gql schema generation
Browse files Browse the repository at this point in the history
  • Loading branch information
gmbronco committed Jan 15, 2025
1 parent c0b8122 commit a28094c
Show file tree
Hide file tree
Showing 55 changed files with 1,201 additions and 1,390 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { gql } from 'apollo-server-express';
import { gql } from 'graphql-request';
export const schema = gql`
#
# THIS FILE IS AUTOGENERATED — DO NOT EDIT IT
Expand Down
2 changes: 1 addition & 1 deletion schema.ts → apps/api/gql/generated-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* THIS FILE IS AUTOGENERATED — DO NOT EDIT IT
*/
import { GraphQLResolveInfo, GraphQLScalarType, GraphQLScalarTypeConfig } from 'graphql';
import { ResolverContext } from './apps/api/gql/resolver-context';
import { ResolverContext } from './resolver-context';
export type Maybe<T> = T | null;
export type InputMaybe<T> = Maybe<T>;
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
Expand Down
2 changes: 1 addition & 1 deletion apps/api/gql/resolvers/beets.resolvers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Resolvers } from '../../../../schema';
import { Resolvers } from '../generated-schema';
import { beetsService } from '../../../../modules/beets/beets.service';
import { getRequiredAccountAddress, isAdminRoute } from '../../../../modules/auth/auth-context';
import { userService } from '../../../../modules/user/user.service';
Expand Down
2 changes: 1 addition & 1 deletion apps/api/gql/resolvers/blocks.resolvers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Resolvers } from '../../../../schema';
import { Resolvers } from '../generated-schema';
import { isAdminRoute } from '../../../../modules/auth/auth-context';
import { blocksSubgraphService } from '../../../../modules/subgraphs/blocks-subgraph/blocks-subgraph.service';

Expand Down
2 changes: 1 addition & 1 deletion apps/api/gql/resolvers/content.resolvers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Resolvers } from '../../../../schema';
import { Resolvers } from '../generated-schema';
import { headerChain } from '../../../../modules/context/header-chain';
import { SanityContentService } from '../../../../modules/content/sanity-content.service';
import { GraphQLError } from 'graphql';
Expand Down
2 changes: 1 addition & 1 deletion apps/api/gql/resolvers/pool.resolvers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { poolService } from '../../../../modules/pool/pool.service';
import { GqlChain, Resolvers } from '../../../../schema';
import { GqlChain, Resolvers } from '../generated-schema';
import { isAdminRoute } from '../../../../modules/auth/auth-context';
import { networkContext } from '../../../../modules/network/network-context.service';
import { headerChain } from '../../../../modules/context/header-chain';
Expand Down
2 changes: 1 addition & 1 deletion apps/api/gql/resolvers/protocol.resolvers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GqlLatestSyncedBlocks, Resolvers } from '../../../../schema';
import { GqlLatestSyncedBlocks, Resolvers } from '../generated-schema';
import { protocolService } from '../../../../modules/protocol/protocol.service';
import { networkContext } from '../../../../modules/network/network-context.service';
import { headerChain } from '../../../../modules/context/header-chain';
Expand Down
2 changes: 1 addition & 1 deletion apps/api/gql/resolvers/scalar.resolvers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Resolvers } from '../../../../schema';
import { Resolvers } from '../generated-schema';
import { GraphQLScalarType, Kind } from 'graphql';

const dateScalar = new GraphQLScalarType<Date | null, string | null>({
Expand Down
2 changes: 1 addition & 1 deletion apps/api/gql/resolvers/sftmx.resolvers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Resolvers } from '../../../../schema';
import { Resolvers } from '../generated-schema';
import { SftmxController } from '../../../../modules/controllers';

const resolvers: Resolvers = {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/gql/resolvers/sor.resolvers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Resolvers } from '../../../../schema';
import { Resolvers } from '../generated-schema';
import { sorService } from '../../../../modules/sor/sor.service';
import { headerChain } from '../../../../modules/context/header-chain';
import { GraphQLError } from 'graphql';
Expand Down
2 changes: 1 addition & 1 deletion apps/api/gql/resolvers/sts.resolvers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Resolvers } from '../../../../schema';
import { Resolvers } from '../generated-schema';
import { StakedSonicController } from '../../../../modules/controllers';

const resolvers: Resolvers = {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/gql/resolvers/token.resolvers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GqlChain, GqlHistoricalTokenPrice, Resolvers } from '../../../../schema';
import { GqlChain, GqlHistoricalTokenPrice, Resolvers } from '../generated-schema';
import _ from 'lodash';
import { isAdminRoute } from '../../../../modules/auth/auth-context';
import { tokenService } from '../../../../modules/token/token.service';
Expand Down
2 changes: 1 addition & 1 deletion apps/api/gql/resolvers/user.resolvers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Resolvers } from '../../../../schema';
import { Resolvers } from '../generated-schema';
import { userService } from '../../../../modules/user/user.service';
import { getRequiredAccountAddress, isAdminRoute } from '../../../../modules/auth/auth-context';
import { tokenService } from '../../../../modules/token/token.service';
Expand Down
2 changes: 1 addition & 1 deletion apps/api/gql/resolvers/vebal.resolvers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Resolvers } from '../../../../schema';
import { Resolvers } from '../generated-schema';
import { getRequiredAccountAddress, isAdminRoute } from '../../../../modules/auth/auth-context';
import { veBalService } from '../../../../modules/vebal/vebal.service';
import { veBalVotingListService } from '../../../../modules/vebal/vebal-voting-list.service';
Expand Down
2 changes: 1 addition & 1 deletion apps/api/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { corsMiddleware, lowerCaseMiddleware, sessionMiddleware } from './middle
import { ApolloServerPluginDrainHttpServer } from '@apollo/server/plugin/drainHttpServer';
import { ApolloServerPluginUsageReporting } from '@apollo/server/plugin/usageReporting';
import { ApolloServerPluginLandingPageLocalDefault } from '@apollo/server/plugin/landingPage/default';
import { schema } from '../../graphql_schema_generated';
import { schema } from './gql/generated-schema-ast';
import { resolvers } from './gql/resolvers';
import { ResolverContext, resolverContext } from './gql/resolver-context';
import { apolloSentryPlugin } from './apollo/sentry-plugin';
Expand Down
8 changes: 4 additions & 4 deletions codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,20 @@ const files = {
},
},
},
['graphql_schema_generated.ts']: {
['apps/api/gql/generated-schema-ast.ts']: {
schema: './apps/api/gql/schema/*.gql',
plugins: [
{
add: {
content:
"import { gql } from 'apollo-server-express';\nexport const schema = gql`\n#\n# THIS FILE IS AUTOGENERATED — DO NOT EDIT IT\n#\n",
"import { gql } from 'graphql-request';\nexport const schema = gql`\n#\n# THIS FILE IS AUTOGENERATED — DO NOT EDIT IT\n#\n",
},
},
'schema-ast',
{ add: { content: '`;', placement: 'append' } },
],
},
['schema.ts']: {
['apps/api/gql/generated-schema.ts']: {
schema: './apps/api/gql/schema/*.gql',
plugins: [
{
Expand All @@ -150,7 +150,7 @@ const files = {
immutableTypes: false,
useIndexSignature: true,
enumsAsTypes: true,
contextType: './apps/api/gql/resolver-context#ResolverContext',
contextType: './resolver-context#ResolverContext',
scalars: {
Date: 'Date',
UUID: 'string',
Expand Down
2 changes: 1 addition & 1 deletion modules/actions/snapshots/pool-snapshot-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
OrderDirection,
PoolSnapshot_OrderBy,
} from '../../subgraphs/balancer-subgraph/generated/balancer-subgraph-types';
import { GqlPoolSnapshotDataRange } from '../../../schema';
import { GqlPoolSnapshotDataRange } from '../../../apps/api/gql/generated-schema';
import moment from 'moment-timezone';
import _ from 'lodash';
import { Chain, PrismaPoolSnapshot } from '@prisma/client';
Expand Down
2 changes: 1 addition & 1 deletion modules/content/content-types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Chain } from '@prisma/client';
import { GqlChain } from '../../schema';
import { GqlChain } from '../../apps/api/gql/generated-schema';

export interface ConfigHomeScreen {
featuredPoolGroups: HomeScreenFeaturedPoolGroup[];
Expand Down
2 changes: 1 addition & 1 deletion modules/controllers/event-query-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
GqlPoolSwapEventV3,
QueryPoolEventsArgs,
GqlPoolSwapEventCowAmm,
} from '../../schema';
} from '../../apps/api/gql/generated-schema';
import { prisma } from '../../prisma/prisma-client';
import { Chain, PoolEventType, Prisma } from '@prisma/client';
import { JoinExitEvent, SwapEvent } from '../../prisma/prisma-types';
Expand Down
2 changes: 1 addition & 1 deletion modules/controllers/sftmx-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
GqlSftmxWithdrawalRequests,
GqlSftmxStakingData,
GqlSftmxStakingSnapshot,
} from '../../schema';
} from '../../apps/api/gql/generated-schema';
import { AllNetworkConfigsKeyedOnChain } from '../network/network-config';

const SFTMX_STACKINGCONTRACT = AllNetworkConfigsKeyedOnChain['FANTOM'].data.sftmx!.stakingContractAddress;
Expand Down
6 changes: 5 additions & 1 deletion modules/controllers/sts-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import config from '../../config';
import { getViemClient } from '../sources/viem-client';
import { Address } from 'viem';
import { prisma } from '../../prisma/prisma-client';
import { GqlStakedSonicData, GqlStakedSonicSnapshot, GqlStakedSonicSnapshotDataRange } from '../../schema';
import {
GqlStakedSonicData,
GqlStakedSonicSnapshot,
GqlStakedSonicSnapshotDataRange,
} from '../../apps/api/gql/generated-schema';
import { syncStakingData } from '../actions/sts/sync-staking-data';
import { StsSubgraphService } from '../sources/subgraphs/sts-subgraph/sts.service';
import { syncSonicStakingSnapshots } from '../actions/sts/sync-staking-snapshots';
Expand Down
2 changes: 1 addition & 1 deletion modules/network/network-config-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { BigNumber } from 'ethers';
import type { PoolAprService } from '../pool/pool-types';
import type { UserStakedBalanceService } from '../user/user-types';
import type { BaseProvider } from '@ethersproject/providers';
import type { GqlChain } from '../../schema';
import type { GqlChain } from '../../apps/api/gql/generated-schema';
import type { ContentService } from '../content/content-types';
import type { YbAprConfig } from './apr-config-types';
import type { BalancerSubgraphService } from '../subgraphs/balancer-subgraph/balancer-subgraph.service';
Expand Down
2 changes: 1 addition & 1 deletion modules/pool/lib/pool-gql-loader.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
GqlPoolAggregator,
LiquidityManagement,
GqlHook,
} from '../../../schema';
} from '../../../apps/api/gql/generated-schema';
import { addressesMatch } from '../../web3/addresses';
import _ from 'lodash';
import { prisma } from '../../../prisma/prisma-client';
Expand Down
2 changes: 1 addition & 1 deletion modules/pool/lib/pool-snapshot.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
OrderDirection,
PoolSnapshot_OrderBy,
} from '../../subgraphs/balancer-subgraph/generated/balancer-subgraph-types';
import { GqlPoolSnapshotDataRange } from '../../../schema';
import { GqlPoolSnapshotDataRange } from '../../../apps/api/gql/generated-schema';
import moment from 'moment-timezone';
import _ from 'lodash';
import { Chain, PrismaPoolSnapshot } from '@prisma/client';
Expand Down
2 changes: 1 addition & 1 deletion modules/pool/lib/pool-swap.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
QueryPoolGetBatchSwapsArgs,
QueryPoolGetJoinExitsArgs,
QueryPoolGetSwapsArgs,
} from '../../../schema';
} from '../../../apps/api/gql/generated-schema';
import { Chain, PrismaPoolSwap } from '@prisma/client';
import _ from 'lodash';
import { isSupportedInt, prismaBulkExecuteOperations } from '../../../prisma/prisma-util';
Expand Down
2 changes: 1 addition & 1 deletion modules/pool/lib/reliquary-snapshot.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { prisma } from '../../../prisma/prisma-client';
import { GqlPoolSnapshotDataRange } from '../../../schema';
import { GqlPoolSnapshotDataRange } from '../../../apps/api/gql/generated-schema';
import moment from 'moment-timezone';
import _ from 'lodash';
import { prismaBulkExecuteOperations } from '../../../prisma/prisma-util';
Expand Down
2 changes: 1 addition & 1 deletion modules/pool/pool.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
QueryPoolGetJoinExitsArgs,
QueryPoolGetPoolsArgs,
QueryPoolGetSwapsArgs,
} from '../../schema';
} from '../../apps/api/gql/generated-schema';
import { blocksSubgraphService } from '../subgraphs/blocks-subgraph/blocks-subgraph.service';
import { tokenService } from '../token/token.service';
import { userService } from '../user/user.service';
Expand Down
2 changes: 1 addition & 1 deletion modules/protocol/protocol.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Chain, PrismaLastBlockSyncedCategory, PrismaUserBalanceType } from '@pr
import _ from 'lodash';
import { networkContext } from '../network/network-context.service';
import { AllNetworkConfigs, AllNetworkConfigsKeyedOnChain } from '../network/network-config';
import { GqlProtocolMetricsAggregated, GqlProtocolMetricsChain } from '../../schema';
import { GqlProtocolMetricsAggregated, GqlProtocolMetricsChain } from '../../apps/api/gql/generated-schema';
import axios from 'axios';

interface LatestSyncedBlocks {
Expand Down
2 changes: 1 addition & 1 deletion modules/sor/sor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
GqlSorGetSwapsResponse,
QuerySorGetSwapPathsArgs,
QuerySorGetSwapsArgs,
} from '../../schema';
} from '../../apps/api/gql/generated-schema';
import { sorV2Service } from './sorV2/sorPathService';
import { GetSwapsV2Input as GetSwapPathsInput } from './types';
import { getToken, getTokenAmountHuman, swapPathsZeroResponse, zeroResponse } from './utils';
Expand Down
2 changes: 1 addition & 1 deletion modules/sor/sorV2/lib/poolsV2/weighted/weightedPool.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PrismaPoolAndHookWithDynamic } from '../../../../../../prisma/prisma-types';
import { GqlPoolType } from '../../../../../../schema';
import { GqlPoolType } from '../../../../../../apps/api/gql/generated-schema';
import { Chain } from '@prisma/client';
import { MathSol, WAD } from '../../utils/math';
import { Address, Hex, parseEther } from 'viem';
Expand Down
2 changes: 1 addition & 1 deletion modules/sor/sorV2/lib/poolsV3/weighted/weightedPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AddKind, RemoveKind, Vault, Weighted, WeightedState, HookState } from '
import { Chain } from '@prisma/client';

import { PrismaPoolAndHookWithDynamic } from '../../../../../../prisma/prisma-types';
import { GqlPoolType } from '../../../../../../schema';
import { GqlPoolType } from '../../../../../../apps/api/gql/generated-schema';
import { TokenPairData } from '../../../../../sources/contracts/v3/fetch-tokenpair-data';
import { chainToChainId as chainToIdMap } from '../../../../../network/chain-id-to-chain';

Expand Down
2 changes: 1 addition & 1 deletion modules/sor/sorV2/sorPathService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
GqlSorSwapRouteHop,
GqlSorSwapType,
GqlSwapCallDataInput,
} from '../../../schema';
} from '../../../apps/api/gql/generated-schema';
import { Chain, Prisma, PrismaPoolType } from '@prisma/client';
import { PrismaPoolAndHookWithDynamic, prismaPoolAndHookWithDynamic } from '../../../prisma/prisma-types';
import { prisma } from '../../../prisma/prisma-client';
Expand Down
2 changes: 1 addition & 1 deletion modules/sor/sorV2/swapResultV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
GqlPoolMinimal,
GqlSorSwapRoute,
GqlSorSwapRouteHop,
} from '../../../schema';
} from '../../../apps/api/gql/generated-schema';
import { Chain } from '@prisma/client';
import { SwapResult } from '../types';
import { poolService } from '../../pool/pool.service';
Expand Down
7 changes: 6 additions & 1 deletion modules/sor/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { Chain } from '@prisma/client';
import { GqlSorSwapType, GqlSorGetSwapsResponse, GqlSorSwapOptionsInput, GqlSwapCallDataInput } from '../../schema';
import {
GqlSorSwapType,
GqlSorGetSwapsResponse,
GqlSorSwapOptionsInput,
GqlSwapCallDataInput,
} from '../../apps/api/gql/generated-schema';
import { TokenAmount } from '@balancer/sdk';
export interface GetSwapsInput {
chain: Chain;
Expand Down
2 changes: 1 addition & 1 deletion modules/sor/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { tokenService } from '../token/token.service';
import { Chain } from '@prisma/client';
import { AllNetworkConfigsKeyedOnChain } from '../network/network-config';
import { chainToChainId as chainToIdMap } from '../network/chain-id-to-chain';
import { GqlSorGetSwapPaths, GqlSorGetSwapsResponse, GqlSorSwapType } from '../../schema';
import { GqlSorGetSwapPaths, GqlSorGetSwapsResponse, GqlSorSwapType } from '../../apps/api/gql/generated-schema';
import { replaceZeroAddressWithEth } from '../web3/addresses';
import { Address } from 'viem';
import { Token, TokenAmount } from '@balancer/sdk';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ export type VaultSchemaHistoricApRsArgs = {
};

export type AllPoolsQueryVariables = Exact<{
chainIds?: Maybe<Array<Scalars['Int']> | Scalars['Int']>;
chainIds?: InputMaybe<Array<Scalars['Int']> | Scalars['Int']>;
}>;

export type AllPoolsQuery = {
Expand All @@ -427,7 +427,7 @@ export type PoolSchemaFragment = {
};

export type AccountsQueryVariables = Exact<{
ids?: Maybe<Array<Scalars['String']> | Scalars['String']>;
ids?: InputMaybe<Array<Scalars['String']> | Scalars['String']>;
}>;

export type AccountsQuery = {
Expand Down Expand Up @@ -515,9 +515,10 @@ export const AccountsDocument = gql`
export type SdkFunctionWrapper = <T>(
action: (requestHeaders?: Record<string, string>) => Promise<T>,
operationName: string,
operationType?: string,
) => Promise<T>;

const defaultWrapper: SdkFunctionWrapper = (action, _operationName) => action();
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType) => action();

export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) {
return {
Expand All @@ -532,6 +533,7 @@ export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper =
...wrappedRequestHeaders,
}),
'allPools',
'query',
);
},
accounts(
Expand All @@ -545,6 +547,7 @@ export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper =
...wrappedRequestHeaders,
}),
'accounts',
'query',
);
},
};
Expand Down
Loading

0 comments on commit a28094c

Please sign in to comment.