Skip to content

Instantly share code, notes, and snippets.

@linonetwo
Last active May 24, 2019 07:53
Show Gist options
  • Save linonetwo/5e9de59d5beb21648bfb932641529b8d to your computer and use it in GitHub Desktop.
Save linonetwo/5e9de59d5beb21648bfb932641529b8d to your computer and use it in GitHub Desktop.
Get fields in fragment of a #graphql query
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