From 2db87dfa702f394d6094a74ff64614b8999cdb69 Mon Sep 17 00:00:00 2001 From: Cesare Naldi Date: Mon, 16 Dec 2024 16:01:29 +0100 Subject: [PATCH] chore: renames account, manager, and common fragments --- packages/graphql/src/accounts/account.ts | 82 ++++++++++++----------- packages/graphql/src/accounts/managers.ts | 18 ++--- packages/graphql/src/accounts/signless.ts | 12 ++-- packages/graphql/src/follow.ts | 4 +- packages/graphql/src/fragments/common.ts | 32 ++++----- packages/graphql/src/fragments/post.ts | 17 +++-- 6 files changed, 87 insertions(+), 78 deletions(-) diff --git a/packages/graphql/src/accounts/account.ts b/packages/graphql/src/accounts/account.ts index f47da7589..4be974022 100644 --- a/packages/graphql/src/accounts/account.ts +++ b/packages/graphql/src/accounts/account.ts @@ -46,15 +46,15 @@ export const AccountsBulkQuery = graphql( ); export type AccountsBulkRequest = RequestOf; -const SetAccountMetadataResponse = graphql( +const SetAccountMetadataResponseFragment = graphql( `fragment SetAccountMetadataResponse on SetAccountMetadataResponse { __typename hash }`, ); -export type SetAccountMetadataResponse = FragmentOf; +export type SetAccountMetadataResponse = FragmentOf; -const SetAccountMetadataResult = graphql( +const SetAccountMetadataResultFragment = graphql( `fragment SetAccountMetadataResult on SetAccountMetadataResult { ...on SetAccountMetadataResponse { ...SetAccountMetadataResponse @@ -73,13 +73,13 @@ const SetAccountMetadataResult = graphql( } }`, [ - SetAccountMetadataResponse, + SetAccountMetadataResponseFragment, SponsoredTransactionRequestFragment, SelfFundedTransactionRequestFragment, TransactionWillFailFragment, ], ); -export type SetAccountMetadataResult = FragmentOf; +export type SetAccountMetadataResult = FragmentOf; export const SetAccountMetadataMutation = graphql( `mutation SetAccountMetadata($request: SetAccountMetadataRequest!) { @@ -87,17 +87,17 @@ export const SetAccountMetadataMutation = graphql( ...SetAccountMetadataResult } }`, - [SetAccountMetadataResult], + [SetAccountMetadataResultFragment], ); export type SetAccountMetadataRequest = RequestOf; -const CreateAccountResponse = graphql( +const CreateAccountResponseFragment = graphql( `fragment CreateAccountResponse on CreateAccountResponse { __typename hash }`, ); -export type CreateAccountResponse = FragmentOf; +export type CreateAccountResponse = FragmentOf; const InvalidUsernameFragment = graphql( `fragment InvalidUsername on InvalidUsername { @@ -107,7 +107,7 @@ const InvalidUsernameFragment = graphql( ); export type InvalidUsername = FragmentOf; -const CreateAccountWithUsernameResult = graphql( +const CreateAccountWithUsernameResultFragment = graphql( `fragment CreateAccountWithUsernameResult on CreateAccountWithUsernameResult { ...on CreateAccountResponse { ...CreateAccountResponse @@ -130,14 +130,16 @@ const CreateAccountWithUsernameResult = graphql( } }`, [ - CreateAccountResponse, + CreateAccountResponseFragment, SponsoredTransactionRequestFragment, SelfFundedTransactionRequestFragment, InvalidUsernameFragment, TransactionWillFailFragment, ], ); -export type CreateAccountWithUsernameResult = FragmentOf; +export type CreateAccountWithUsernameResult = FragmentOf< + typeof CreateAccountWithUsernameResultFragment +>; export const CreateAccountWithUsernameMutation = graphql( `mutation CreateAccountWithUsername($request: CreateAccountWithUsernameRequest!) { @@ -145,12 +147,12 @@ export const CreateAccountWithUsernameMutation = graphql( ...CreateAccountWithUsernameResult } }`, - [CreateAccountWithUsernameResult], + [CreateAccountWithUsernameResultFragment], ); export type CreateAccountWithUsernameRequest = RequestOf; -const AccountFeedsStats = graphql( +const AccountFeedsStatsFragment = graphql( `fragment AccountFeedsStats on AccountFeedsStats { __typename posts @@ -162,18 +164,18 @@ const AccountFeedsStats = graphql( collects }`, ); -export type AccountFeedsStats = FragmentOf; +export type AccountFeedsStats = FragmentOf; -const AccountGraphsFollowStats = graphql( +const AccountGraphsFollowStatsFragment = graphql( `fragment AccountGraphsFollowStats on AccountGraphsFollowStats { __typename followers following }`, ); -export type AccountGraphsFollowStats = FragmentOf; +export type AccountGraphsFollowStats = FragmentOf; -const AccountStats = graphql( +const AccountStatsFragment = graphql( `fragment AccountStats on AccountStats { __typename feedStats { @@ -183,9 +185,9 @@ const AccountStats = graphql( ...AccountGraphsFollowStats } }`, - [AccountFeedsStats, AccountGraphsFollowStats], + [AccountFeedsStatsFragment, AccountGraphsFollowStatsFragment], ); -export type AccountStats = FragmentOf; +export type AccountStats = FragmentOf; export const AccountFeedsStatsQuery = graphql( `query AccountFeedsStats($request: AccountFeedsStatsRequest!) { @@ -193,7 +195,7 @@ export const AccountFeedsStatsQuery = graphql( ...AccountFeedsStats } }`, - [AccountFeedsStats], + [AccountFeedsStatsFragment], ); export type AccountFeedsStatsRequest = RequestOf; @@ -204,7 +206,7 @@ export const AccountStatsQuery = graphql( ...AccountStats } }`, - [AccountStats], + [AccountStatsFragment], ); export type AccountStatsRequest = RequestOf; @@ -215,7 +217,7 @@ export const AccountGraphsStatsQuery = graphql( ...AccountGraphsFollowStats } }`, - [AccountGraphsFollowStats], + [AccountGraphsFollowStatsFragment], ); export type AccountGraphsStatsRequest = RequestOf; @@ -273,23 +275,23 @@ export const ReportAccountMutation = graphql( ); export type ReportAccountRequest = RequestOf; -const BlockError = graphql( +const BlockErrorFragment = graphql( `fragment BlockError on BlockError { __typename error }`, ); -export type BlockError = FragmentOf; +export type BlockError = FragmentOf; -const BlockResponse = graphql( +const BlockResponseFragment = graphql( `fragment BlockResponse on BlockResponse { __typename hash }`, ); -export type BlockResponse = FragmentOf; +export type BlockResponse = FragmentOf; -const BlockResult = graphql( +const BlockResultFragment = graphql( `fragment BlockResult on BlockResult { ...on BlockResponse { ...BlockResponse @@ -308,13 +310,13 @@ const BlockResult = graphql( } }`, [ - BlockResponse, + BlockResponseFragment, SponsoredTransactionRequestFragment, SelfFundedTransactionRequestFragment, - BlockError, + BlockErrorFragment, ], ); -export type BlockResult = FragmentOf; +export type BlockResult = FragmentOf; export const BlockMutation = graphql( `mutation Block($request: BlockRequest!) { @@ -322,27 +324,27 @@ export const BlockMutation = graphql( ...BlockResult } }`, - [BlockResult], + [BlockResultFragment], ); export type BlockRequest = RequestOf; -const UnblockResponse = graphql( +const UnblockResponseFragment = graphql( `fragment UnblockResponse on UnblockResponse { __typename hash }`, ); -export type UnblockResponse = FragmentOf; +export type UnblockResponse = FragmentOf; -const UnblockError = graphql( +const UnblockErrorFragment = graphql( `fragment UnblockError on UnblockError { __typename error }`, ); -export type UnblockError = FragmentOf; +export type UnblockError = FragmentOf; -const UnblockResult = graphql( +const UnblockResultFragment = graphql( `fragment UnblockResult on UnblockResult { ...on UnblockResponse { ...UnblockResponse @@ -358,13 +360,13 @@ const UnblockResult = graphql( } }`, [ - UnblockResponse, + UnblockResponseFragment, SponsoredTransactionRequestFragment, SelfFundedTransactionRequestFragment, - UnblockError, + UnblockErrorFragment, ], ); -export type UnblockResult = FragmentOf; +export type UnblockResult = FragmentOf; export const UnblockMutation = graphql( `mutation Unblock($request: UnblockRequest!) { @@ -372,7 +374,7 @@ export const UnblockMutation = graphql( ...UnblockResult } }`, - [UnblockResult], + [UnblockResultFragment], ); export type UnblockRequest = RequestOf; diff --git a/packages/graphql/src/accounts/managers.ts b/packages/graphql/src/accounts/managers.ts index 5301e59ca..288c1a88e 100644 --- a/packages/graphql/src/accounts/managers.ts +++ b/packages/graphql/src/accounts/managers.ts @@ -24,7 +24,7 @@ export const AccountManagersQuery = graphql( export type AccountManagersRequest = RequestOf; -const AddAccountManagerResult = graphql( +const AddAccountManagerResultFragment = graphql( `fragment AddAccountManagerResult on AddAccountManagerResult{ ...on SponsoredTransactionRequest { ...SponsoredTransactionRequest @@ -42,7 +42,7 @@ const AddAccountManagerResult = graphql( TransactionWillFailFragment, ], ); -export type AddAccountManagerResult = FragmentOf; +export type AddAccountManagerResult = FragmentOf; export const AddAccountManagerMutation = graphql( `mutation AddAccountManager($request: AddAccountManagerRequest!) { @@ -50,11 +50,11 @@ export const AddAccountManagerMutation = graphql( ...AddAccountManagerResult } }`, - [AddAccountManagerResult], + [AddAccountManagerResultFragment], ); export type AddAccountManagerRequest = RequestOf; -const RemoveAccountManagerResult = graphql( +const RemoveAccountManagerResultFragment = graphql( `fragment RemoveAccountManagerResult on RemoveAccountManagerResult{ ...on SponsoredTransactionRequest { ...SponsoredTransactionRequest @@ -72,7 +72,7 @@ const RemoveAccountManagerResult = graphql( TransactionWillFailFragment, ], ); -export type RemoveAccountManagerResult = FragmentOf; +export type RemoveAccountManagerResult = FragmentOf; export const RemoveAccountManagerMutation = graphql( `mutation RemoveAccountManager($request: RemoveAccountManagerRequest!) { @@ -80,11 +80,11 @@ export const RemoveAccountManagerMutation = graphql( ...RemoveAccountManagerResult } }`, - [RemoveAccountManagerResult], + [RemoveAccountManagerResultFragment], ); export type RemoveAccountManagerRequest = RequestOf; -const UpdateAccountManagerResult = graphql( +const UpdateAccountManagerResultFragment = graphql( `fragment UpdateAccountManagerResult on UpdateAccountManagerResult{ ...on SponsoredTransactionRequest { ...SponsoredTransactionRequest @@ -102,7 +102,7 @@ const UpdateAccountManagerResult = graphql( TransactionWillFailFragment, ], ); -export type UpdateAccountManagerResult = FragmentOf; +export type UpdateAccountManagerResult = FragmentOf; export const UpdateAccountManagerMutation = graphql( `mutation RemoveAccountManager($request: UpdateAccountManagerRequest!) { @@ -110,7 +110,7 @@ export const UpdateAccountManagerMutation = graphql( ...UpdateAccountManagerResult } }`, - [UpdateAccountManagerResult], + [UpdateAccountManagerResultFragment], ); export type UpdateAccountManagerRequest = RequestOf; diff --git a/packages/graphql/src/accounts/signless.ts b/packages/graphql/src/accounts/signless.ts index f7fc46d4f..6fcec27ca 100644 --- a/packages/graphql/src/accounts/signless.ts +++ b/packages/graphql/src/accounts/signless.ts @@ -7,7 +7,7 @@ import { } from '../fragments'; import { graphql } from '../graphql'; -const EnableSignlessResult = graphql( +const EnableSignlessResultFragment = graphql( `fragment EnableSignlessResult on EnableSignlessResult{ ...on SponsoredTransactionRequest { ...SponsoredTransactionRequest @@ -25,7 +25,7 @@ const EnableSignlessResult = graphql( TransactionWillFailFragment, ], ); -export type EnableSignlessResult = FragmentOf; +export type EnableSignlessResult = FragmentOf; export const EnableSignlessMutation = graphql( `mutation EnableSignless { @@ -33,10 +33,10 @@ export const EnableSignlessMutation = graphql( ...EnableSignlessResult } }`, - [EnableSignlessResult], + [EnableSignlessResultFragment], ); -const RemoveSignlessResult = graphql( +const RemoveSignlessResultFragment = graphql( `fragment RemoveSignlessResult on RemoveSignlessResult{ ...on SponsoredTransactionRequest { ...SponsoredTransactionRequest @@ -54,7 +54,7 @@ const RemoveSignlessResult = graphql( TransactionWillFailFragment, ], ); -export type RemoveSignlessResult = FragmentOf; +export type RemoveSignlessResult = FragmentOf; export const RemoveSignlessMutation = graphql( `mutation RemoveSignless { @@ -62,5 +62,5 @@ export const RemoveSignlessMutation = graphql( ...RemoveSignlessResult } }`, - [RemoveSignlessResult], + [RemoveSignlessResultFragment], ); diff --git a/packages/graphql/src/follow.ts b/packages/graphql/src/follow.ts index 69d74fc26..a469c9f93 100644 --- a/packages/graphql/src/follow.ts +++ b/packages/graphql/src/follow.ts @@ -2,7 +2,7 @@ import type { FragmentOf } from 'gql.tada'; import { AccountFragment, - BooleanValue, + BooleanValueFragment, PaginatedResultInfoFragment, SelfFundedTransactionRequestFragment, SponsoredTransactionRequestFragment, @@ -176,7 +176,7 @@ const FollowStatusResultFragment = graphql( ...BooleanValue } }`, - [BooleanValue], + [BooleanValueFragment], ); export type FollowStatusResult = FragmentOf; diff --git a/packages/graphql/src/fragments/common.ts b/packages/graphql/src/fragments/common.ts index 1e071852b..09b3f2ec3 100644 --- a/packages/graphql/src/fragments/common.ts +++ b/packages/graphql/src/fragments/common.ts @@ -1,32 +1,34 @@ import type { FragmentOf } from 'gql.tada'; import { graphql } from '../graphql'; -export const BooleanValue = graphql( +export const BooleanValueFragment = graphql( `fragment BooleanValue on BooleanValue { __typename optimistic onChain }`, ); -export type BooleanValue = FragmentOf; +export type BooleanValue = FragmentOf; -export const NetworkAddress = graphql( +export const NetworkAddressFragment = graphql( `fragment NetworkAddress on NetworkAddress { __typename address chainId }`, ); -export type NetworkAddress = FragmentOf; +export type NetworkAddress = FragmentOf; /** * A value that can be in three statuses: YES, NO, or UNKNOWN. * * UNKNOWN implies that it was not possible to determine the value. + * + * @deprecated Use new OperationOutcome once on the API */ export type TriStateValue = ReturnType>; -export const Erc20 = graphql( +export const Erc20Fragment = graphql( `fragment Erc20 on Erc20 { __typename name @@ -36,21 +38,21 @@ export const Erc20 = graphql( ...NetworkAddress } }`, - [NetworkAddress], + [NetworkAddressFragment], ); -export type Erc20 = FragmentOf; +export type Erc20 = FragmentOf; -export const Asset = graphql( +export const AssetFragment = graphql( `fragment Asset on Asset { ...on Erc20 { ...Erc20 } }`, - [Erc20], + [Erc20Fragment], ); -export type Asset = FragmentOf; +export type Asset = FragmentOf; -export const Amount = graphql( +export const AmountFragment = graphql( `fragment Amount on Amount { __typename asset { @@ -58,15 +60,15 @@ export const Amount = graphql( } value }`, - [Asset], + [AssetFragment], ); -export type Amount = FragmentOf; +export type Amount = FragmentOf; -export const ActionInputInfo = graphql( +export const ActionInputInfoFragment = graphql( `fragment ActionInputInfo on ActionInputInfo { __typename type name }`, ); -export type ActionInputInfo = FragmentOf; +export type ActionInputInfo = FragmentOf; diff --git a/packages/graphql/src/fragments/post.ts b/packages/graphql/src/fragments/post.ts index 3f80042b9..07f60d104 100644 --- a/packages/graphql/src/fragments/post.ts +++ b/packages/graphql/src/fragments/post.ts @@ -1,7 +1,12 @@ import type { FragmentOf } from 'gql.tada'; import { graphql } from '../graphql'; import { AccountFragment } from './account'; -import { ActionInputInfo, Amount, BooleanValue, NetworkAddress } from './common'; +import { + ActionInputInfoFragment, + AmountFragment, + BooleanValueFragment, + NetworkAddressFragment, +} from './common'; import { ArticleMetadataFragment, AudioMetadataFragment, @@ -48,7 +53,7 @@ export const SimpleCollectActionSettingsFragment = graphql( ...RecipientDataOutput } }`, - [Amount, NetworkAddress, RecipientDataOutputFragment], + [AmountFragment, NetworkAddressFragment, RecipientDataOutputFragment], ); export type SimpleCollectActionSettingsFragment = FragmentOf< typeof SimpleCollectActionSettingsFragment @@ -65,7 +70,7 @@ export const UnknownActionSettingsFragment = graphql( } collectNft }`, - [NetworkAddress], + [NetworkAddressFragment], ); export type UnknownActionSettings = FragmentOf; @@ -168,7 +173,7 @@ export const LoggedInPostOperationsFragment = graphql( ...BooleanValue } }`, - [BooleanValue], + [BooleanValueFragment], ); export type LoggedInPostOperations = FragmentOf; @@ -314,7 +319,7 @@ export const KnownActionFragment = graphql( ...NetworkAddress } }`, - [NetworkAddress, ActionInputInfo], + [NetworkAddressFragment, ActionInputInfoFragment], ); export type KnownAction = FragmentOf; @@ -326,7 +331,7 @@ export const UnknownActionFragment = graphql( ...NetworkAddress } }`, - [NetworkAddress], + [NetworkAddressFragment], ); export type UnknownAction = FragmentOf;