import Web3 from 'web3' ; import { getConstant } from '../constants' ; export async function query ( network , graphQLQuery , variables ? ) ; export async function query ( web3 , graphQLQuery , variables ? ) ; export async function query ( networkOrWeb3 , graphQLQuery , variables ? ) { let subgraphURL ; if ( typeof networkOrWeb3 === 'string' ) { subgraphURL = await getConstant ( 'subgraphURL' , networkOrWeb3 ) ; } else { subgraphURL = await getConstant ( 'subgraphURL' , networkOrWeb3 ) ; } let response = await fetch ( subgraphURL , { method : 'POST' , headers : { 'Content-Type' : 'application/json' , Accept : 'application/json' , } , body : JSON . stringify ( { query : graphQLQuery , variables , } ) , } ) ; return await response . json ( ) ; }