Selaa lähdekoodia

20230218: GraphQL-Integration : Fixed issue on Council.gql

mkbeefcake 1 vuosi sitten
vanhempi
commit
f481453cfb

+ 1 - 1
codegen.yml

@@ -1,6 +1,6 @@
 overwrite: true
 
-schema: 'https://query.joystream.org/graphql'
+schema: 'https://tiguan08.com/graphql'
 
 documents:
   - './src/queries/**/*.gql'

+ 2 - 1
src/components/Dashboard/index.tsx

@@ -19,7 +19,8 @@ const Dashboard = (props: IProps) => {
   const _description2 = "new tokens minted size of budget at end of period amount of debt at end of period number of workers at end of period"
 
   const { data } = useElectedCouncils({});
-
+  console.log(data)
+  
   return (
     <div style={{ flexGrow: 1 }}>
       <Container maxWidth="xl">

+ 20 - 20
src/queries/__generated__/baseTypes.generated.ts

@@ -1234,7 +1234,7 @@ export type AuctionTypeEnglish = {
   /** Auction extension time */
   extensionPeriod: Scalars['Int'];
   /** Minimal step between auction bids */
-  minimalBidStep: Scalars['BigInt'];
+  minimalBidStep: Scalars['Float'];
   /** Block when auction is supposed to end */
   plannedEndAtBlock: Scalars['Int'];
 };
@@ -2512,7 +2512,7 @@ export type BountyEntryStatusRejected = {
 
 export type BountyEntryStatusWinner = {
   __typename: 'BountyEntryStatusWinner';
-  reward: Scalars['BigInt'];
+  reward: Scalars['Float'];
 };
 
 export type BountyEntryStatusWithdrawn = {
@@ -2715,15 +2715,15 @@ export type BountyFundingLimited = {
   /** Maximum allowed funding period */
   fundingPeriod: Scalars['Int'];
   /** Upper boundary for a bounty funding */
-  maxFundingAmount: Scalars['BigInt'];
+  maxFundingAmount: Scalars['Float'];
   /** Minimum amount of funds for a successful bounty */
-  minFundingAmount: Scalars['BigInt'];
+  minFundingAmount: Scalars['Float'];
 };
 
 export type BountyFundingPerpetual = {
   __typename: 'BountyFundingPerpetual';
   /** Desired funding */
-  target: Scalars['BigInt'];
+  target: Scalars['Float'];
 };
 
 export type BountyFundingType = BountyFundingLimited | BountyFundingPerpetual;
@@ -8698,7 +8698,7 @@ export type CouncilStage = CouncilStageAnnouncing | CouncilStageElection | Counc
 export type CouncilStageAnnouncing = {
   __typename: 'CouncilStageAnnouncing';
   /** Number of candidates aspiring to be elected as council members. */
-  candidatesCount: Scalars['BigInt'];
+  candidatesCount: Scalars['Float'];
   /** Block number at which the stage ends */
   endsAt: Scalars['Int'];
 };
@@ -8706,7 +8706,7 @@ export type CouncilStageAnnouncing = {
 export type CouncilStageElection = {
   __typename: 'CouncilStageElection';
   /** Number of candidates aspiring to be elected as council members. */
-  candidatesCount: Scalars['BigInt'];
+  candidatesCount: Scalars['Float'];
 };
 
 export type CouncilStageIdle = {
@@ -8959,9 +8959,9 @@ export type CreateWorkingGroupLeadOpeningProposalDetails = {
   /** The opening metadata */
   metadata?: Maybe<WorkingGroupOpeningMetadata>;
   /** Initial workers' reward per block */
-  rewardPerBlock: Scalars['BigInt'];
+  rewardPerBlock: Scalars['Float'];
   /** Min. application / role stake amount */
-  stakeAmount: Scalars['BigInt'];
+  stakeAmount: Scalars['Float'];
   /** Role stake unstaking period in blocks */
   unstakingPeriod: Scalars['Int'];
 };
@@ -9359,7 +9359,7 @@ export type DataObjectTypeVideoThumbnail = {
 export type DecreaseWorkingGroupLeadStakeProposalDetails = {
   __typename: 'DecreaseWorkingGroupLeadStakeProposalDetails';
   /** Amount to decrease the stake by */
-  amount: Scalars['BigInt'];
+  amount: Scalars['Float'];
   /** The lead that should be affected */
   lead?: Maybe<Worker>;
 };
@@ -27536,19 +27536,19 @@ export type SearchSearchResult = Channel | Video;
 export type SetCouncilBudgetIncrementProposalDetails = {
   __typename: 'SetCouncilBudgetIncrementProposalDetails';
   /** New (proposed) amount the council budget should be increased by per each budget period */
-  newAmount: Scalars['BigInt'];
+  newAmount: Scalars['Float'];
 };
 
 export type SetCouncilorRewardProposalDetails = {
   __typename: 'SetCouncilorRewardProposalDetails';
   /** New (proposed) council members' reward per block */
-  newRewardPerBlock: Scalars['BigInt'];
+  newRewardPerBlock: Scalars['Float'];
 };
 
 export type SetInitialInvitationBalanceProposalDetails = {
   __typename: 'SetInitialInvitationBalanceProposalDetails';
   /** The new (proposed) initial balance credited to controller account of an invitee (locked for transaction fee payments only) */
-  newInitialInvitationBalance: Scalars['BigInt'];
+  newInitialInvitationBalance: Scalars['Float'];
 };
 
 export type SetInitialInvitationCountProposalDetails = {
@@ -27572,7 +27572,7 @@ export type SetMembershipLeadInvitationQuotaProposalDetails = {
 export type SetMembershipPriceProposalDetails = {
   __typename: 'SetMembershipPriceProposalDetails';
   /** New (proposed) membership price */
-  newPrice: Scalars['BigInt'];
+  newPrice: Scalars['Float'];
 };
 
 export type SetReferralCutProposalDetails = {
@@ -27586,7 +27586,7 @@ export type SetWorkingGroupLeadRewardProposalDetails = {
   /** The lead that should be affected */
   lead?: Maybe<Worker>;
   /** Lead's new (proposed) reward per block */
-  newRewardPerBlock: Scalars['BigInt'];
+  newRewardPerBlock: Scalars['Float'];
 };
 
 export type SignalProposalDetails = {
@@ -27598,7 +27598,7 @@ export type SignalProposalDetails = {
 export type SlashWorkingGroupLeadProposalDetails = {
   __typename: 'SlashWorkingGroupLeadProposalDetails';
   /** Amount to slash the stake by */
-  amount: Scalars['BigInt'];
+  amount: Scalars['Float'];
   /** The lead that should be affected */
   lead?: Maybe<Worker>;
 };
@@ -29310,7 +29310,7 @@ export type TerminateWorkingGroupLeadProposalDetails = {
   /** Lead that's supposed to be terminated */
   lead?: Maybe<Worker>;
   /** Optionally - the amount to slash the lead's stake by */
-  slashingAmount?: Maybe<Scalars['BigInt']>;
+  slashingAmount?: Maybe<Scalars['Float']>;
 };
 
 export type TerminatedLeaderEvent = BaseGraphQlObject & Event & {
@@ -30366,7 +30366,7 @@ export type TransactionalStatus = TransactionalStatusBuyNow | TransactionalStatu
 
 export type TransactionalStatusBuyNow = {
   __typename: 'TransactionalStatusBuyNow';
-  price: Scalars['BigInt'];
+  price: Scalars['Float'];
 };
 
 export type TransactionalStatusIdle = {
@@ -30380,7 +30380,7 @@ export type TransactionalStatusInitiatedOfferToMember = {
   /** Member identifier */
   memberId: Scalars['Int'];
   /** Whether member should pay to accept offer (optional) */
-  price?: Maybe<Scalars['BigInt']>;
+  price?: Maybe<Scalars['Float']>;
 };
 
 export type TransactionalStatusUpdate = BaseGraphQlObject & {
@@ -30631,7 +30631,7 @@ export type UpcomingWorkingGroupOpeningWhereUniqueInput = {
 export type UpdateWorkingGroupBudgetProposalDetails = {
   __typename: 'UpdateWorkingGroupBudgetProposalDetails';
   /** Amount to increase / decrease the working group budget by (will be decudted from / appended to council budget accordingly) */
-  amount: Scalars['BigInt'];
+  amount: Scalars['Float'];
   /** Related working group */
   group?: Maybe<WorkingGroup>;
 };

+ 6 - 3
src/queries/__generated__/councilMembers.generated.tsx

@@ -3,15 +3,17 @@ import * as Types from './baseTypes.generated';
 import { gql } from '@apollo/client';
 import * as Apollo from '@apollo/client';
 const defaultOptions = {} as const;
-export type GetCouncilMembersQueryVariables = Types.Exact<{ [key: string]: never; }>;
+export type GetCouncilMembersQueryVariables = Types.Exact<{
+  where?: Types.InputMaybe<Types.CouncilMemberWhereInput>;
+}>;
 
 
 export type GetCouncilMembersQuery = { __typename: 'Query', councilMembers: Array<{ __typename: 'CouncilMember', electedInCouncilId: string, member: { __typename: 'Membership', handle: string } }> };
 
 
 export const GetCouncilMembersDocument = gql`
-    query getCouncilMembers {
-  councilMembers {
+    query getCouncilMembers($where: CouncilMemberWhereInput) {
+  councilMembers(where: $where) {
     electedInCouncilId
     member {
       handle
@@ -32,6 +34,7 @@ export const GetCouncilMembersDocument = gql`
  * @example
  * const { data, loading, error } = useGetCouncilMembersQuery({
  *   variables: {
+ *      where: // value for 'where'
  *   },
  * });
  */

+ 6 - 4
src/queries/__generated__/councils.generated.tsx

@@ -1,6 +1,7 @@
 import * as Types from './baseTypes.generated';
 
 import { gql } from '@apollo/client';
+import { MemberFieldsFragmentDoc } from './members.generated';
 import * as Apollo from '@apollo/client';
 const defaultOptions = {} as const;
 export type GetElectedCouncilsQueryVariables = Types.Exact<{
@@ -11,16 +12,17 @@ export type GetElectedCouncilsQueryVariables = Types.Exact<{
 }>;
 
 
-export type GetElectedCouncilsQuery = { __typename: 'Query', electedCouncils: Array<{ __typename: 'ElectedCouncil', id: string, electedAtBlock: number, endedAtBlock?: number | null, electedAtTime: any, endedAtTime?: any | null, electedAtNetwork: Types.Network, endedAtNetwork?: Types.Network | null, councilElections: Array<{ __typename: 'ElectionRound', cycleId: number }>, councilMembers: Array<{ __typename: 'CouncilMember', id: string, unpaidReward: string, stake: string, member: { __typename: 'Membership', councilMembers: Array<{ __typename: 'CouncilMember' }> } }> }> };
+export type GetElectedCouncilsQuery = { __typename: 'Query', electedCouncils: Array<{ __typename: 'ElectedCouncil', id: string, electedAtBlock: number, endedAtBlock?: number | null, electedAtTime: any, endedAtTime?: any | null, electedAtNetwork: Types.Network, endedAtNetwork?: Types.Network | null, councilElections: Array<{ __typename: 'ElectionRound', cycleId: number }>, councilMembers: Array<{ __typename: 'CouncilMember', id: string, unpaidReward: string, stake: string, member: { __typename: 'Membership', id: string, rootAccount: string, controllerAccount: string, boundAccounts: Array<string>, handle: string, isVerified: boolean, isFoundingMember: boolean, isCouncilMember: boolean, inviteCount: number, createdAt: any, councilMembers: Array<{ __typename: 'CouncilMember' }>, metadata: { __typename: 'MemberMetadata', name?: string | null, about?: string | null, avatar?: { __typename: 'AvatarObject' } | { __typename: 'AvatarUri', avatarUri: string } | null }, roles: Array<{ __typename: 'Worker', id: string, createdAt: any, isLead: boolean, group: { __typename: 'WorkingGroup', name: string } }>, stakingaccountaddedeventmember?: Array<{ __typename: 'StakingAccountAddedEvent', createdAt: any, inBlock: number, network: Types.Network, account: string }> | null } }> }> };
 
-export type ElectedCouncilFieldsFragment = { __typename: 'ElectedCouncil', id: string, electedAtBlock: number, endedAtBlock?: number | null, electedAtTime: any, endedAtTime?: any | null, electedAtNetwork: Types.Network, endedAtNetwork?: Types.Network | null, councilElections: Array<{ __typename: 'ElectionRound', cycleId: number }>, councilMembers: Array<{ __typename: 'CouncilMember', id: string, unpaidReward: string, stake: string, member: { __typename: 'Membership', councilMembers: Array<{ __typename: 'CouncilMember' }> } }> };
+export type ElectedCouncilFieldsFragment = { __typename: 'ElectedCouncil', id: string, electedAtBlock: number, endedAtBlock?: number | null, electedAtTime: any, endedAtTime?: any | null, electedAtNetwork: Types.Network, endedAtNetwork?: Types.Network | null, councilElections: Array<{ __typename: 'ElectionRound', cycleId: number }>, councilMembers: Array<{ __typename: 'CouncilMember', id: string, unpaidReward: string, stake: string, member: { __typename: 'Membership', id: string, rootAccount: string, controllerAccount: string, boundAccounts: Array<string>, handle: string, isVerified: boolean, isFoundingMember: boolean, isCouncilMember: boolean, inviteCount: number, createdAt: any, councilMembers: Array<{ __typename: 'CouncilMember' }>, metadata: { __typename: 'MemberMetadata', name?: string | null, about?: string | null, avatar?: { __typename: 'AvatarObject' } | { __typename: 'AvatarUri', avatarUri: string } | null }, roles: Array<{ __typename: 'Worker', id: string, createdAt: any, isLead: boolean, group: { __typename: 'WorkingGroup', name: string } }>, stakingaccountaddedeventmember?: Array<{ __typename: 'StakingAccountAddedEvent', createdAt: any, inBlock: number, network: Types.Network, account: string }> | null } }> };
 
-export type CouncilMemberFieldsFragment = { __typename: 'CouncilMember', id: string, unpaidReward: string, stake: string, member: { __typename: 'Membership', councilMembers: Array<{ __typename: 'CouncilMember' }> } };
+export type CouncilMemberFieldsFragment = { __typename: 'CouncilMember', id: string, unpaidReward: string, stake: string, member: { __typename: 'Membership', id: string, rootAccount: string, controllerAccount: string, boundAccounts: Array<string>, handle: string, isVerified: boolean, isFoundingMember: boolean, isCouncilMember: boolean, inviteCount: number, createdAt: any, councilMembers: Array<{ __typename: 'CouncilMember' }>, metadata: { __typename: 'MemberMetadata', name?: string | null, about?: string | null, avatar?: { __typename: 'AvatarObject' } | { __typename: 'AvatarUri', avatarUri: string } | null }, roles: Array<{ __typename: 'Worker', id: string, createdAt: any, isLead: boolean, group: { __typename: 'WorkingGroup', name: string } }>, stakingaccountaddedeventmember?: Array<{ __typename: 'StakingAccountAddedEvent', createdAt: any, inBlock: number, network: Types.Network, account: string }> | null } };
 
 export const CouncilMemberFieldsFragmentDoc = gql`
     fragment CouncilMemberFields on CouncilMember {
   id
   member {
+    ...MemberFields
     councilMembers {
       __typename
     }
@@ -28,7 +30,7 @@ export const CouncilMemberFieldsFragmentDoc = gql`
   unpaidReward
   stake
 }
-    `;
+    ${MemberFieldsFragmentDoc}`;
 export const ElectedCouncilFieldsFragmentDoc = gql`
     fragment ElectedCouncilFields on ElectedCouncil {
   id

+ 2 - 2
src/queries/councilMembers.gql

@@ -1,5 +1,5 @@
-query getCouncilMembers{
-  councilMembers{
+query getCouncilMembers($where:CouncilMemberWhereInput){
+  councilMembers(where:$where){
     electedInCouncilId
     member{
       handle

+ 1 - 0
src/queries/councils.gql

@@ -30,6 +30,7 @@ fragment ElectedCouncilFields on ElectedCouncil {
 fragment CouncilMemberFields on CouncilMember {
   id
   member {
+    ...MemberFields
     councilMembers {
       __typename
     }

+ 2 - 1
src/queries/index.tsx

@@ -11,4 +11,5 @@ export * from './__generated__/videos.generated';
 export * from './__generated__/workingGroups.generated';
 export * from './__generated__/tokens.generated';
 export * from './__generated__/workers.generated';
-export * from './__generated__/councilMember.generated';
+export * from './__generated__/councilMembers.generated';
+export * from './patched/index';

+ 8 - 0
src/queries/patched/index.ts

@@ -0,0 +1,8 @@
+import * as Types from '../__generated__/baseTypes.generated';
+
+import { gql } from '@apollo/client';
+import * as Apollo from '@apollo/client';
+
+const defaultOptions = {} as const;
+
+export type CouncilMemberFragment = { __typename: 'CouncilMember', electedInCouncilId: string, member: { handle: string } };

+ 2 - 2
src/types/Member.ts

@@ -68,8 +68,8 @@ export interface MemberWithDetails extends Member {
 export const asMember = (data: Omit<MemberFieldsFragment, '__typename'>): Member => ({
   id: data.id,
   handle: data.handle,
-  name: data.metadata.name ?? undefined,
-  avatar: castQueryResult(data.metadata.avatar, 'AvatarUri')?.avatarUri,
+  // name: data.metadata?.name ?? undefined,
+  // avatar: "", /*castQueryResult(data.metadata.avatar, 'AvatarUri')?.avatarUri ?? "",*/
   inviteCount: data.inviteCount,
   isFoundingMember: data.isFoundingMember,
   isCouncilMember: data.isCouncilMember,