Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Added GraphQL #1461

Merged
merged 8 commits into from
May 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions docs/Pantheon-API/GraphQL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
description: How to access the Pantheon API using GraphQL
<!--- END of page meta data -->

# GraphQL over HTTP

GraphQL can reduce the overhead needed for common queries. For example, instead of querying each receipt in a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good explanation of the advantages but does not match the title that makes me expect specific things about making GraphQL requests over HTTP.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NicolasMassart - Do you mean there's nothing about why you'd use GraphQL over HTTP specifically? HTTP is the only option for GraphQL. I thought about removing the transport method from the titles but have just recently specifically added it to make it it clearer the RPC Sub/Pub API is over WebSockets to make it more findable.

block, GraphQL can obtain the same result with a single query for the entire block.

## GraphQL Requests with Curl

[Pantheon JSON-RPC API methods](../Reference/Pantheon-API-Methods.md) with an equivalent [GraphQL](../Pantheon-API/GraphQL.md)
query include a GraphQL request and result in the method example.

!!! example
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we just explaining in one line what this example request does : "Returns an result with data about the synchronization status" as it's described in the API ref.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

The following [`syncing`](../Reference/Pantheon-API-Methods.md#eth_syncing) request returns data about the synchronization status.
```bash
curl -X POST -H "Content-Type: application/json" --data '{ "query": "{syncing{startingBlock currentBlock highestBlock}}"}' http://localhost:8547/graphql
```

## GraphQL Requests with GraphiQL App

The third-party tool [GraphiQL](https://github.com/skevy/graphiql-app) provides a tabbed interface for editing and testing GraphQL
queries and mutations. GraphiQL also provides access the Pantheon GraphQL schema from within the app.

![GraphiQL](../images/GraphiQL.png)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The screenshot should display the same query as in cURL request for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed




32 changes: 31 additions & 1 deletion docs/Pantheon-API/Pantheon-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,40 @@ Access the [Pantheon API](../Reference/Pantheon-API-Methods.md) using:

* [JSON-RPC over HTTP or WebSockets](Using-JSON-RPC-API.md)
* [RPC Pub/Sub over WebSockets](RPC-PubSub.md)
* GraphQL RPC over HTTP
* [GraphQL over HTTP](GraphQL.md)

Information applying to JSON-RPC, RPC Pub/Sub, and GraphQL is included below.

## Enabling API Access

Use the [`--rpc-http-enabled`](../Reference/Pantheon-CLI-Syntax.md#rpc-http-enabled), [`--ws-http-enabled`](../Reference/Pantheon-CLI-Syntax.md#rpc-ws-enabled),
and [`--graphql-http-enabled`](../Reference/Pantheon-CLI-Syntax.md#graphql-http-enabled) options to enable API access.

## Service Hosts

Use the [`--rpc-http-host`](../Reference/Pantheon-CLI-Syntax.md#rpc-http-host), [`--rpc-ws-host`](../Reference/Pantheon-CLI-Syntax.md#rpc-ws-host),
and [`--graphql-http-host`](../Reference/Pantheon-CLI-Syntax.md#graphql-http-host) options to specify the host on which the API service listens.
The default host is 127.0.0.1.

Set the host to `0.0.0.0` to allow remote connections.

!!! caution
Setting the host to 0.0.0.0 exposes the API service connection on your node to any remote connection. In a
production environment, ensure you use a firewall to avoid exposing your node to the internet.

## Service Ports

Use the [`--rpc-http-port`](../Reference/Pantheon-CLI-Syntax.md#rpc-http-port), [`--rpc-ws-port`](../Reference/Pantheon-CLI-Syntax.md#rpc-ws-port),
and [`--graphql-http-port`](../Reference/Pantheon-CLI-Syntax.md#graphql-http-port) options to specify the port on which the API service listens.

The default ports are:

* 8545 for JSON-RPC over HTTP
* 8546 for JSON-RPC over WebSockets
* 8547 for GraphQL over HTTP

Ports must be [exposed appropriately](../Configuring-Pantheon/Networking/Managing-Peers.md#port-configuration).

## Host Whitelist

To prevent DNS rebinding, incoming HTTP requests, WebSockets connections, and GraphQL requests are only accepted from hostnames
Expand Down
21 changes: 0 additions & 21 deletions docs/Pantheon-API/Using-JSON-RPC-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,6 @@ description: How to access the Pantheon API using JSON-RPC
To enable JSON-RPC over HTTP or WebSockets, use the [`--rpc-http-enabled`](../Reference/Pantheon-CLI-Syntax.md#rpc-http-enabled)
and [`--rpc-ws-enabled`](../Reference/Pantheon-CLI-Syntax.md#rpc-ws-enabled) options.

## RPC Host

Use the [--rpc-http-host](../Reference/Pantheon-CLI-Syntax.md#rpc-http-host) and [--rpc-ws-host](../Reference/Pantheon-CLI-Syntax.md#rpc-ws-host)
options to specify the host on which the JSON-RPC listens. The default host is 127.0.0.1 for HTTP and WebSockets.

Set the host to `0.0.0.0` to allow remote connections.

!!! caution
Setting the host to 0.0.0.0 exposes the RPC connection on your node to any remote connection. In a
production environment, ensure you use a firewall to avoid exposing your node to the internet.

## RPC Port

Use the [--rpc-http-port](../Reference/Pantheon-CLI-Syntax.md#rpc-http-port) and [--rpc-ws-port](../Reference/Pantheon-CLI-Syntax.md#rpc-ws-port)
options to specify the port on which the JSON-RPC listens. The default ports are:

* 8545 for HTTP
* 8546 for WebSockets

Ports must be [exposed appropriately](../Configuring-Pantheon/Networking/Managing-Peers.md#port-configuration).

## Postman

Use the button to import our collection of examples to [Postman](https://www.getpostman.com/).
Expand Down
Loading