--http
flags and the --graphql
flag should be passed to the Parallax client:
http://localhost:8545/graphql
. To change the port, provide a custom port number to --http.port
, e.g.:
GraphiQL
An easy way to try out queries is the GraphiQL interface shipped with the Parallax client. To open it visithttp://localhost:8545/graphql/ui
. To see how this works let’s read the sender, recipient and value of all transactions in block number 6000000. In GraphiQL:
Root Types
click on Query
to see the high-level types and their fields.
Query
Reading out data from the Parallax client is the biggest use-case for GraphQL. In addition to using the UI queries can also be sent programmatically. The official GraphQL docs explain how to find bindings for many languages, or send http requests from the terminal using tools such as Curl. For example, the code snippet below shows how to obtain the latest block number using Curl. Note the use of a JSON object for the data section:graphql-request
is used to perform the request. Note the use of variables instead of hardcoding the block number in the query: