Skip to content

Commit

Permalink
Added versioning suffix to the GraphQL endpoint (#1725)
Browse files Browse the repository at this point in the history
Closes #1661
  • Loading branch information
xgreenx committed Mar 4, 2024
1 parent 799d800 commit 19470f8
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

#### Breaking

- [#1725](https://github.com/FuelLabs/fuel-core/pull/1725): All API endpoints now are prefixed with `/v1` version. New usage looks like: `/v1/playground`, `/v1/graphql`, `/v1/graphql-sub`, `/v1/metrics`, `/v1/health`.
- [#1722](https://github.com/FuelLabs/fuel-core/pull/1722): Bugfix: Zero `predicate_gas_used` field during validation of the produced block.
- [#1714](https://github.com/FuelLabs/fuel-core/pull/1714): The change bumps the `fuel-vm` to `0.47.1`. It breaks several breaking changes into the protocol:
- All malleable fields are zero during the execution and unavailable through the GTF getters. Accessing them via the memory directly is still possible, but they are zero.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ The client functionality is available through a service endpoint that expect Gra

The transaction executor currently performs instant block production. Changes are persisted to RocksDB by default.

- Service endpoint: `/graphql`
- Service endpoint: `/v1/graphql`
- Schema (available after building): `crates/client/assets/schema.sdl`

The service expects a mutation defined as `submit` that receives a [Transaction](https://github.com/FuelLabs/fuel-vm/tree/master/fuel-tx) in hex encoded binary format, as [specified here](https://github.com/FuelLabs/fuel-specs/blob/master/src/tx-format/transaction.md).
Expand Down
4 changes: 2 additions & 2 deletions crates/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl FromStr for FuelClient {
let mut url = reqwest::Url::parse(&raw_url)
.map_err(anyhow::Error::msg)
.with_context(|| format!("Invalid fuel-core URL: {str}"))?;
url.set_path("/graphql");
url.set_path("/v1/graphql");

#[cfg(feature = "subscriptions")]
{
Expand Down Expand Up @@ -245,7 +245,7 @@ impl FuelClient {
use hyper_rustls as _;
use reqwest::cookie::CookieStore;
let mut url = self.url.clone();
url.set_path("/graphql-sub");
url.set_path("/v1/graphql-sub");
let json_query = serde_json::to_string(&q)?;
let mut client_builder = es::ClientBuilder::for_url(url.as_str())
.map_err(|e| {
Expand Down
14 changes: 8 additions & 6 deletions crates/fuel-core/src/graphql_api/api_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,14 @@ where
.finish();

let router = Router::new()
.route("/playground", get(graphql_playground))
.route("/graphql", post(graphql_handler).options(ok))
.route("/v1/playground", get(graphql_playground))
.route("/v1/graphql", post(graphql_handler).options(ok))
.route(
"/graphql-sub",
"/v1/graphql-sub",
post(graphql_subscription_handler).options(ok),
)
.route("/metrics", get(metrics))
.route("/health", get(health))
.route("/v1/metrics", get(metrics))
.route("/v1/health", get(health))
.layer(Extension(schema))
.layer(TraceLayer::new_for_http())
.layer(TimeoutLayer::new(request_timeout))
Expand Down Expand Up @@ -235,7 +235,9 @@ where
}

async fn graphql_playground() -> impl IntoResponse {
Html(playground_source(GraphQLPlaygroundConfig::new("/graphql")))
Html(playground_source(GraphQLPlaygroundConfig::new(
"/v1/graphql",
)))
}

async fn health() -> Json<serde_json::Value> {
Expand Down
4 changes: 2 additions & 2 deletions deployment/charts/templates/fuel-core-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
matchLabels:
app: {{ .Values.app.selector_name }}
endpoints:
- path: /metrics
- path: /v1/metrics
port: http
{{- end }}
---
Expand Down Expand Up @@ -271,7 +271,7 @@ spec:
protocol: TCP
livenessProbe:
httpGet:
path: /health
path: /v1/health
port: {{ .Values.app.target_port }}
initialDelaySeconds: 300
periodSeconds: 5
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async fn test_metrics_endpoint() {
.await
.unwrap();

let resp = reqwest::get(format!("http://{}/metrics", srv.bound_address))
let resp = reqwest::get(format!("http://{}/v1/metrics", srv.bound_address))
.await
.unwrap()
.text()
Expand Down

0 comments on commit 19470f8

Please sign in to comment.