Skip to content

Commit

Permalink
fix graphql issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaut committed Dec 4, 2024
1 parent 6a87504 commit a9cf269
Show file tree
Hide file tree
Showing 14 changed files with 114 additions and 61 deletions.
12 changes: 8 additions & 4 deletions packages/ui/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,15 @@
"extends": "plugin:@graphql-eslint/schema-recommended",
"rules": {
"@graphql-eslint/known-type-names": "error"
}
},
"parserOptions": {
"schema": "https://chainsafe.squids.live/multix-arrow/v/v4/graphql"
{
"files": ["*.graphql"],
"extends": ["plugin:@graphql-eslint/operations-recommended"],
"rules": {
"@graphql-eslint/require-selections": "error"
}
}
}
],
"ignorePatterns": ["src/interfaces/**/*", "types-and-hooks.tsx", "src/gql/**/*"]
"ignorePatterns": ["src/interfaces/**/*", "types-and-hooks.tsx", "build"]
}
2 changes: 0 additions & 2 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@
"lint:types": "tsc --pretty",
"lint:fix": "yarn run lint --fix",
"codegen": "graphql-codegen --config graphql.config.json",
"generate:type-from-defs": "dlx ts-node --skip-project node_modules/.bin/polkadot-types-from-defs --endpoint ./node-metadata.json --package src/interfaces --input ./src/interfaces",
"generate:types-from-chain": "dlx ts-node --skip-project node_modules/.bin/polkadot-types-from-chain --endpoint wss://rpc.ibp.network/polkadot --output ./src/interfaces",
"test": "cypress open",
"test:ci": "cypress run --browser chrome --headless",
"postinstall": "yarn papi"
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/contexts/MultiProxyContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { createContext, useCallback, useContext, useEffect, useMemo, useS
import {
MultisigsBySignatoriesOrWatchedQuery,
ProxyType,
PureByIdsQueryQuery
PureByIdsQuery
} from '../../types-and-hooks'
import { AccountBaseInfo } from '../components/select/GenericAccountSelection'
import { useQueryMultisigs } from '../hooks/useQueryMultisigs'
Expand Down Expand Up @@ -233,7 +233,7 @@ const MultiProxyContextProvider = ({ children }: MultisigContextProps) => {
[watchedAddresses]
)

const refreshPureList = useCallback((data: PureByIdsQueryQuery) => {
const refreshPureList = useCallback((data: PureByIdsQuery) => {
const pureProxyMap = new Map<string, Omit<MultiProxy, 'proxy'>>()
// we do have an answer, but there is nothing
if (!!data?.accounts && data.accounts.length === 0) {
Expand Down
26 changes: 23 additions & 3 deletions packages/ui/src/gql/fragment-masking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,45 @@ export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: FragmentType<DocumentTypeDecoration<TType, any>>
): TType;
// return nullable if `fragmentType` is undefined
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | undefined
): TType | undefined;
// return nullable if `fragmentType` is nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | null
): TType | null;
// return nullable if `fragmentType` is nullable or undefined
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | null | undefined
): TType | null | undefined;
// return array of non-nullable if `fragmentType` is array of non-nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>>>
): Array<TType>;
// return array of nullable if `fragmentType` is array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
): Array<TType> | null | undefined;
// return readonly array of non-nullable if `fragmentType` is array of non-nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>
): ReadonlyArray<TType>;
// return array of nullable if `fragmentType` is array of nullable
// return readonly array of nullable if `fragmentType` is array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
): ReadonlyArray<TType> | null | undefined;
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
): TType | ReadonlyArray<TType> | null | undefined {
fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | Array<FragmentType<DocumentTypeDecoration<TType, any>>> | ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
): TType | Array<TType> | ReadonlyArray<TType> | null | undefined {
return fragmentType as any;
}

Expand Down
21 changes: 11 additions & 10 deletions packages/ui/src/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
"query MultisigById($id: String!) {\n accounts(where: {id_eq: $id, isMultisig_eq: true}) {\n signatories(limit: 50) {\n signatory {\n id\n address\n }\n }\n threshold\n id\n }\n}": types.MultisigByIdDocument,
"query MultisigCallsByMultisigId($multisigs: [String!]) {\n multisigCalls(\n limit: 10\n orderBy: timestamp_DESC\n where: {multisig: {id_in: $multisigs}}\n ) {\n blockHash\n callIndex\n id\n timestamp\n }\n}": types.MultisigCallsByMultisigIdDocument,
"query multisigsByMultisigOrPureSignatories($accountIds: [String!]) {\n accountMultisigs(where: {signatory: {id_in: $accountIds}}, limit: 10) {\n multisig {\n address\n threshold\n signatories(limit: 10) {\n signatory {\n address\n }\n }\n }\n }\n}": types.MultisigsByMultisigOrPureSignatoriesDocument,
"query MultisigsBySignatoriesOrWatched($accountIds: [String!], $watchedAccountIds: [String!]) {\n accountMultisigs(\n where: {OR: [{multisig: {id_in: $watchedAccountIds}}, {signatory: {id_in: $accountIds}}, {signatory: {id_in: $watchedAccountIds}}]}\n limit: 500\n ) {\n multisig {\n address\n threshold\n signatories(limit: 100) {\n signatory {\n address\n }\n }\n delegateeFor(limit: 100) {\n type\n delegator {\n address\n isPureProxy\n }\n }\n }\n }\n}": types.MultisigsBySignatoriesOrWatchedDocument,
"query PureByIdsQuery($pureIds: [String!]) {\n accounts(where: {AND: [{id_in: $pureIds}, {isPureProxy_eq: true}]}, limit: 50) {\n address\n delegatorFor(limit: 50) {\n id\n type\n delegatee {\n address\n isMultisig\n threshold\n signatories(limit: 50) {\n signatory {\n address\n }\n }\n }\n }\n }\n}": types.PureByIdsQueryDocument,
"query MultisigById($id: String!) {\n accounts(where: {id_eq: $id, isMultisig_eq: true}) {\n id\n threshold\n signatories(limit: 50) {\n id\n signatory {\n id\n address\n }\n }\n }\n}": types.MultisigByIdDocument,
"query MultisigCallsByMultisigId($multisigs: [String!]) {\n multisigCalls(\n limit: 10\n orderBy: timestamp_DESC\n where: {multisig: {id_in: $multisigs}}\n ) {\n id\n blockHash\n callIndex\n timestamp\n }\n}": types.MultisigCallsByMultisigIdDocument,
"query MultisigsByMultisigOrPureSignatories($accountIds: [String!]) {\n accountMultisigs(where: {signatory: {id_in: $accountIds}}, limit: 10) {\n id\n multisig {\n id\n address\n threshold\n signatories(limit: 10) {\n id\n signatory {\n id\n address\n }\n }\n }\n }\n}": types.MultisigsByMultisigOrPureSignatoriesDocument,
"query MultisigsBySignatoriesOrWatched($accountIds: [String!], $watchedAccountIds: [String!]) {\n accountMultisigs(\n where: {OR: [{multisig: {id_in: $watchedAccountIds}}, {signatory: {id_in: $accountIds}}, {signatory: {id_in: $watchedAccountIds}}]}\n limit: 500\n ) {\n id\n multisig {\n id\n address\n threshold\n signatories(limit: 100) {\n id\n signatory {\n id\n address\n }\n }\n delegateeFor(limit: 100) {\n id\n type\n delegator {\n id\n address\n isPureProxy\n }\n }\n }\n }\n}": types.MultisigsBySignatoriesOrWatchedDocument,
"query PureByIds($pureIds: [String!]) {\n accounts(where: {AND: [{id_in: $pureIds}, {isPureProxy_eq: true}]}, limit: 50) {\n id\n address\n delegatorFor(limit: 50) {\n id\n type\n delegatee {\n id\n address\n isMultisig\n threshold\n signatories(limit: 50) {\n id\n signatory {\n id\n address\n }\n }\n }\n }\n }\n}": types.PureByIdsDocument,
};

/**
Expand All @@ -37,23 +38,23 @@ export function graphql(source: string): unknown;
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "query MultisigById($id: String!) {\n accounts(where: {id_eq: $id, isMultisig_eq: true}) {\n signatories(limit: 50) {\n signatory {\n id\n address\n }\n }\n threshold\n id\n }\n}"): (typeof documents)["query MultisigById($id: String!) {\n accounts(where: {id_eq: $id, isMultisig_eq: true}) {\n signatories(limit: 50) {\n signatory {\n id\n address\n }\n }\n threshold\n id\n }\n}"];
export function graphql(source: "query MultisigById($id: String!) {\n accounts(where: {id_eq: $id, isMultisig_eq: true}) {\n id\n threshold\n signatories(limit: 50) {\n id\n signatory {\n id\n address\n }\n }\n }\n}"): (typeof documents)["query MultisigById($id: String!) {\n accounts(where: {id_eq: $id, isMultisig_eq: true}) {\n id\n threshold\n signatories(limit: 50) {\n id\n signatory {\n id\n address\n }\n }\n }\n}"];
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "query MultisigCallsByMultisigId($multisigs: [String!]) {\n multisigCalls(\n limit: 10\n orderBy: timestamp_DESC\n where: {multisig: {id_in: $multisigs}}\n ) {\n blockHash\n callIndex\n id\n timestamp\n }\n}"): (typeof documents)["query MultisigCallsByMultisigId($multisigs: [String!]) {\n multisigCalls(\n limit: 10\n orderBy: timestamp_DESC\n where: {multisig: {id_in: $multisigs}}\n ) {\n blockHash\n callIndex\n id\n timestamp\n }\n}"];
export function graphql(source: "query MultisigCallsByMultisigId($multisigs: [String!]) {\n multisigCalls(\n limit: 10\n orderBy: timestamp_DESC\n where: {multisig: {id_in: $multisigs}}\n ) {\n id\n blockHash\n callIndex\n timestamp\n }\n}"): (typeof documents)["query MultisigCallsByMultisigId($multisigs: [String!]) {\n multisigCalls(\n limit: 10\n orderBy: timestamp_DESC\n where: {multisig: {id_in: $multisigs}}\n ) {\n id\n blockHash\n callIndex\n timestamp\n }\n}"];
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "query multisigsByMultisigOrPureSignatories($accountIds: [String!]) {\n accountMultisigs(where: {signatory: {id_in: $accountIds}}, limit: 10) {\n multisig {\n address\n threshold\n signatories(limit: 10) {\n signatory {\n address\n }\n }\n }\n }\n}"): (typeof documents)["query multisigsByMultisigOrPureSignatories($accountIds: [String!]) {\n accountMultisigs(where: {signatory: {id_in: $accountIds}}, limit: 10) {\n multisig {\n address\n threshold\n signatories(limit: 10) {\n signatory {\n address\n }\n }\n }\n }\n}"];
export function graphql(source: "query MultisigsByMultisigOrPureSignatories($accountIds: [String!]) {\n accountMultisigs(where: {signatory: {id_in: $accountIds}}, limit: 10) {\n id\n multisig {\n id\n address\n threshold\n signatories(limit: 10) {\n id\n signatory {\n id\n address\n }\n }\n }\n }\n}"): (typeof documents)["query MultisigsByMultisigOrPureSignatories($accountIds: [String!]) {\n accountMultisigs(where: {signatory: {id_in: $accountIds}}, limit: 10) {\n id\n multisig {\n id\n address\n threshold\n signatories(limit: 10) {\n id\n signatory {\n id\n address\n }\n }\n }\n }\n}"];
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "query MultisigsBySignatoriesOrWatched($accountIds: [String!], $watchedAccountIds: [String!]) {\n accountMultisigs(\n where: {OR: [{multisig: {id_in: $watchedAccountIds}}, {signatory: {id_in: $accountIds}}, {signatory: {id_in: $watchedAccountIds}}]}\n limit: 500\n ) {\n multisig {\n address\n threshold\n signatories(limit: 100) {\n signatory {\n address\n }\n }\n delegateeFor(limit: 100) {\n type\n delegator {\n address\n isPureProxy\n }\n }\n }\n }\n}"): (typeof documents)["query MultisigsBySignatoriesOrWatched($accountIds: [String!], $watchedAccountIds: [String!]) {\n accountMultisigs(\n where: {OR: [{multisig: {id_in: $watchedAccountIds}}, {signatory: {id_in: $accountIds}}, {signatory: {id_in: $watchedAccountIds}}]}\n limit: 500\n ) {\n multisig {\n address\n threshold\n signatories(limit: 100) {\n signatory {\n address\n }\n }\n delegateeFor(limit: 100) {\n type\n delegator {\n address\n isPureProxy\n }\n }\n }\n }\n}"];
export function graphql(source: "query MultisigsBySignatoriesOrWatched($accountIds: [String!], $watchedAccountIds: [String!]) {\n accountMultisigs(\n where: {OR: [{multisig: {id_in: $watchedAccountIds}}, {signatory: {id_in: $accountIds}}, {signatory: {id_in: $watchedAccountIds}}]}\n limit: 500\n ) {\n id\n multisig {\n id\n address\n threshold\n signatories(limit: 100) {\n id\n signatory {\n id\n address\n }\n }\n delegateeFor(limit: 100) {\n id\n type\n delegator {\n id\n address\n isPureProxy\n }\n }\n }\n }\n}"): (typeof documents)["query MultisigsBySignatoriesOrWatched($accountIds: [String!], $watchedAccountIds: [String!]) {\n accountMultisigs(\n where: {OR: [{multisig: {id_in: $watchedAccountIds}}, {signatory: {id_in: $accountIds}}, {signatory: {id_in: $watchedAccountIds}}]}\n limit: 500\n ) {\n id\n multisig {\n id\n address\n threshold\n signatories(limit: 100) {\n id\n signatory {\n id\n address\n }\n }\n delegateeFor(limit: 100) {\n id\n type\n delegator {\n id\n address\n isPureProxy\n }\n }\n }\n }\n}"];
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "query PureByIdsQuery($pureIds: [String!]) {\n accounts(where: {AND: [{id_in: $pureIds}, {isPureProxy_eq: true}]}, limit: 50) {\n address\n delegatorFor(limit: 50) {\n id\n type\n delegatee {\n address\n isMultisig\n threshold\n signatories(limit: 50) {\n signatory {\n address\n }\n }\n }\n }\n }\n}"): (typeof documents)["query PureByIdsQuery($pureIds: [String!]) {\n accounts(where: {AND: [{id_in: $pureIds}, {isPureProxy_eq: true}]}, limit: 50) {\n address\n delegatorFor(limit: 50) {\n id\n type\n delegatee {\n address\n isMultisig\n threshold\n signatories(limit: 50) {\n signatory {\n address\n }\n }\n }\n }\n }\n}"];
export function graphql(source: "query PureByIds($pureIds: [String!]) {\n accounts(where: {AND: [{id_in: $pureIds}, {isPureProxy_eq: true}]}, limit: 50) {\n id\n address\n delegatorFor(limit: 50) {\n id\n type\n delegatee {\n id\n address\n isMultisig\n threshold\n signatories(limit: 50) {\n id\n signatory {\n id\n address\n }\n }\n }\n }\n }\n}"): (typeof documents)["query PureByIds($pureIds: [String!]) {\n accounts(where: {AND: [{id_in: $pureIds}, {isPureProxy_eq: true}]}, limit: 50) {\n id\n address\n delegatorFor(limit: 50) {\n id\n type\n delegatee {\n id\n address\n isMultisig\n threshold\n signatories(limit: 50) {\n id\n signatory {\n id\n address\n }\n }\n }\n }\n }\n}"];

export function graphql(source: string) {
return (documents as any)[source] ?? {};
Expand Down
Loading

0 comments on commit a9cf269

Please sign in to comment.