Closed huahuayu closed 3 years ago
this project is for building graphql schemas. If your intent is to query some publicly available graphql API using go you can do so either with http calls using the request protocol or finding a graphql client library for go (like https://github.com/shurcooL/graphql or https://github.com/machinebox/graphql). In either case this would not be the package you want to use for that.
If you are trying to build your own api that queries uniswap's graphql api, the above still holds true for making the requests but you can put all of your request code into a resolver and proxy the data through your own graphql api.
@bhoriuchi thx for reply, I have made a demo for grqphql query in here https://github.com/huahuayu/graphql , but not use graphql-go, from the example, looks like a little complex.
@huahuayu can this issue be closed then?
@bhoriuchi Could you please show me how to do the query by graphql-go
{
pair(id: "0xa478c2975ab1ea89e8196811f51a7b7ade33eb11"){
token0 {
id
symbol
name
derivedETH
}
token1 {
id
symbol
name
derivedETH
}
reserve0
reserve1
reserveUSD
trackedReserveETH
token0Price
token1Price
volumeUSD
txCount
}
}
here you can test the query online: https://thegraph.com/explorer/subgraph/uniswap/uniswap-v2
you already did it in your example at https://github.com/huahuayu/graphql/blob/main/main.go . This project is not a client package it is used to generate graphql schemas. If you are attempting to query data from a public graphql endpoint you need to use a client package as i mentioned earlier.
The only other thing you can do but would be way more work would be to introspect the public graphql endpoint and dynamically generate resolvers then dynamically create a schema object and use execute on that. But that is way more work than just using a client package. I believe this is what the older version of the apollo client for javascript does for schema stitching
@bhoriuchi got you, thx for your explain.
hi, can I use graphql-go to query uniswap (a blockchain defi project) data in this site?
https://thegraph.com/explorer/subgraph/uniswap/uniswap-v2
all their examples are in javascript...I wonder if I can use go
it's the same protocol or not?