Last active
May 24, 2019 07:53
-
-
Save linonetwo/5e9de59d5beb21648bfb932641529b8d to your computer and use it in GitHub Desktop.
Get fields in fragment of a #graphql query
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
async producers(_: any, __: any, ___: any, { fragments }: Object) { | |
const fields = flatten(values(fragments).map(data => data.selectionSet.selections.map(f => f.name.value))); | |
if ( | |
intersection(fields, [ | |
'owner', | |
'totalVotes', | |
'producerKey', | |
'isActive', | |
'url', | |
'unpaidBlocks', | |
'lastClaimTime', | |
'location', | |
]).length > 0 | |
) { | |
const bpList = await postEOS('/chain/get_table_rows', { | |
json: true, | |
code: 'eosio', | |
scope: 'eosio', | |
table: 'producers', | |
limit: 100000, | |
}); | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment