-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[@kadena/graph] Query, Object and Field descriptions
- Loading branch information
Showing
27 changed files
with
259 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@kadena/graph': patch | ||
--- | ||
|
||
Added descriptions to objects, fields and queries |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,44 @@ | ||
import { getChainModuleAccount } from '@services/account-service'; | ||
import { chainIds } from '@utils/chains'; | ||
import { builder } from '../builder'; | ||
import Account from '../objects/ModuleAccount'; | ||
import { ModuleAccountName } from '../types/graphql-types'; | ||
import { ChainModuleAccount, ModuleAccountName } from '../types/graphql-types'; | ||
|
||
builder.queryField('account', (t) => { | ||
return t.field({ | ||
builder.queryField('account', (t) => | ||
t.field({ | ||
description: 'Find an account by its name and its module, such as coin.', | ||
nullable: true, | ||
args: { | ||
accountName: t.arg.string({ required: true }), | ||
moduleName: t.arg.string({ required: true }), | ||
}, | ||
type: Account, | ||
resolve(__parent, args) { | ||
async resolve(__parent, args) { | ||
const chainAccounts = ( | ||
await Promise.all( | ||
chainIds.map(async (chainId) => { | ||
return await getChainModuleAccount({ | ||
chainId: chainId, | ||
moduleName: args.moduleName, | ||
accountName: args.accountName, | ||
}); | ||
}), | ||
) | ||
).filter((chainAccount) => chainAccount !== null) as ChainModuleAccount[]; | ||
|
||
if (chainAccounts.length === 0) { | ||
return null; | ||
} | ||
|
||
return { | ||
__typename: ModuleAccountName, | ||
accountName: args.accountName, | ||
moduleName: args.moduleName, | ||
chainAccounts: [], | ||
chainAccounts: chainAccounts, | ||
totalBalance: 0, | ||
transactions: [], | ||
transfers: [], | ||
}; | ||
}, | ||
}); | ||
}); | ||
}), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.