Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(graphql): Remove versioning support #19191

Merged
merged 1 commit into from
Sep 3, 2024
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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 3 additions & 15 deletions crates/sui-graphql-e2e-tests/tests/call/simple.exp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
processed 26 tasks
processed 25 tasks

init:
validator_0: object(0,0)
Expand Down Expand Up @@ -114,11 +114,11 @@ task 15, lines 63-68:
Headers: {
"content-type": "application/json",
"content-length": "157",
"x-sui-rpc-version": "2024.7.0-testing-no-sha",
"x-sui-rpc-version": "42.43.44-testing-no-sha",
"vary": "origin, access-control-request-method, access-control-request-headers",
"access-control-allow-origin": "*",
}
Service version: 2024.7.0-testing-no-sha
Service version: 42.43.44-testing-no-sha
Response: {
"data": {
"checkpoint": {
Expand Down Expand Up @@ -314,15 +314,3 @@ task 24, line 181:
created: object(24,0)
mutated: object(0,1)
gas summary: computation_cost: 235000, storage_cost: 2302800, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 25, lines 183-188:
//# run-graphql
Response: {
"data": {
"serviceConfig": {
"availableVersions": [
"2024.7"
]
}
}
}
7 changes: 0 additions & 7 deletions crates/sui-graphql-e2e-tests/tests/call/simple.move
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,3 @@ module Test::M1 {
//# run Test::M1::create --args 0 @A --gas-price 1000

//# run Test::M1::create --args 0 @A --gas-price 235

//# run-graphql
{
serviceConfig {
availableVersions
}
}
2 changes: 1 addition & 1 deletion crates/sui-graphql-rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sui-graphql-rpc"
version = "2024.7.0"
version.workspace = true
authors = ["Mysten Labs <[email protected]>"]
license = "Apache-2.0"
publish = false
Expand Down
4 changes: 0 additions & 4 deletions crates/sui-graphql-rpc/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3470,10 +3470,6 @@ type ServiceConfig {
"""
isEnabled(feature: Feature!): Boolean!
"""
List the available versions for this GraphQL service.
"""
availableVersions: [String!]!
"""
List of all features that are enabled on this GraphQL service.
"""
enabledFeatures: [Feature!]!
Expand Down
57 changes: 14 additions & 43 deletions crates/sui-graphql-rpc/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ pub struct ConnectionConfig {
#[GraphQLConfig]
#[derive(Default)]
pub struct ServiceConfig {
pub versions: Versions,
pub limits: Limits,
pub disabled_features: BTreeSet<FunctionalGroup>,
pub experiments: Experiments,
Expand All @@ -70,11 +69,6 @@ pub struct ServiceConfig {
pub move_registry: MoveRegistryConfig,
}

#[GraphQLConfig]
pub struct Versions {
versions: Vec<String>,
}

#[GraphQLConfig]
pub struct Limits {
/// Maximum depth of nodes in the requests.
Expand Down Expand Up @@ -148,37 +142,31 @@ pub(crate) enum ResolutionType {
/// The `full` version is `year.month.patch-sha`.
#[derive(Copy, Clone, Debug)]
pub struct Version {
/// The year of this release.
pub year: &'static str,
/// The month of this release.
pub month: &'static str,
/// The patch is a positive number incremented for every compatible release on top of the major.month release.
/// The major version for the release
pub major: &'static str,
/// The minor version of the release
pub minor: &'static str,
/// The patch version of the release
pub patch: &'static str,
/// The commit sha for this release.
/// The full commit SHA that the release was built from
pub sha: &'static str,
/// The full version string.
/// Note that this extra field is used only for the uptime_metric function which requries a
/// &'static str.
/// The full version string: {MAJOR}.{MINOR}.{PATCH}-{SHA}
///
/// The full version is pre-computed as a &'static str because that is what is required for
/// `uptime_metric`.
pub full: &'static str,
}

impl Version {
/// Use for testing when you need the Version obj and a year.month &str
pub fn for_testing() -> Self {
Self {
year: env!("CARGO_PKG_VERSION_MAJOR"),
month: env!("CARGO_PKG_VERSION_MINOR"),
patch: env!("CARGO_PKG_VERSION_PATCH"),
major: "42",
minor: "43",
patch: "44",
sha: "testing-no-sha",
// note that this full field is needed for metrics but not for testing
full: const_str::concat!(
env!("CARGO_PKG_VERSION_MAJOR"),
".",
env!("CARGO_PKG_VERSION_MINOR"),
".",
env!("CARGO_PKG_VERSION_PATCH"),
"-testing-no-sha"
),
full: "42.43.44-testing-no-sha",
}
}
}
Expand Down Expand Up @@ -230,11 +218,6 @@ impl ServiceConfig {
!self.disabled_features.contains(&feature)
}

/// List the available versions for this GraphQL service.
async fn available_versions(&self) -> Vec<String> {
self.versions.versions.clone()
}

/// List of all features that are enabled on this GraphQL service.
async fn enabled_features(&self) -> Vec<FunctionalGroup> {
FunctionalGroup::all()
Expand Down Expand Up @@ -504,18 +487,6 @@ impl MoveRegistryConfig {
}
}

impl Default for Versions {
fn default() -> Self {
Self {
versions: vec![format!(
"{}.{}",
env!("CARGO_PKG_VERSION_MAJOR"),
env!("CARGO_PKG_VERSION_MINOR")
)],
}
}
}

impl Default for Ide {
fn default() -> Self {
Self {
Expand Down
15 changes: 1 addition & 14 deletions crates/sui-graphql-rpc/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

use async_graphql::{ErrorExtensionValues, ErrorExtensions, Pos, Response, ServerError};
use async_graphql_axum::GraphQLResponse;
use async_graphql::{ErrorExtensionValues, ErrorExtensions, Pos, ServerError};
use sui_indexer::errors::IndexerError;
use sui_json_rpc::name_service::NameServiceError;

Expand All @@ -12,24 +11,12 @@ use crate::types::dot_move::error::MoveRegistryError;
/// GraphQL.
/// `<https://www.apollographql.com/docs/apollo-server/data/errors/#built-in-error-codes>`
pub(crate) mod code {
pub const BAD_REQUEST: &str = "BAD_REQUEST";
pub const BAD_USER_INPUT: &str = "BAD_USER_INPUT";
pub const INTERNAL_SERVER_ERROR: &str = "INTERNAL_SERVER_ERROR";
pub const REQUEST_TIMEOUT: &str = "REQUEST_TIMEOUT";
pub const UNKNOWN: &str = "UNKNOWN";
}

/// Create a GraphQL Response containing an Error.
///
/// Most errors produced by the service will automatically be wrapped in a `GraphQLResponse`,
/// because they will originate from within the GraphQL implementation. This function is intended
/// for errors that originated from outside of GraphQL (such as in middleware), but that need to be
/// ingested by GraphQL clients.
pub(crate) fn graphql_error_response(code: &str, message: impl Into<String>) -> GraphQLResponse {
let error = graphql_error(code, message);
Response::from_errors(error.into()).into()
}

/// Create a generic GraphQL Server Error.
///
/// This error has no path, source, or locations, just a message and an error code.
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-graphql-rpc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ bin_version::git_revision!();

// VERSION mimics what other sui binaries use for the same const
static VERSION: Version = Version {
year: env!("CARGO_PKG_VERSION_MAJOR"),
month: env!("CARGO_PKG_VERSION_MINOR"),
major: env!("CARGO_PKG_VERSION_MAJOR"),
minor: env!("CARGO_PKG_VERSION_MINOR"),
patch: env!("CARGO_PKG_VERSION_PATCH"),
sha: GIT_REVISION,
full: const_str::concat!(
Expand Down
6 changes: 1 addition & 5 deletions crates/sui-graphql-rpc/src/server/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use crate::{
query_limits_checker::{PayloadSize, QueryLimitsChecker, ShowUsage},
timeout::Timeout,
},
server::version::{check_version_middleware, set_version_middleware},
server::version::set_version_middleware,
types::query::{Query, SuiGraphQLSchema},
};
use async_graphql::extensions::ApolloTracing;
Expand Down Expand Up @@ -351,10 +351,6 @@ impl ServerBuilder {
state.version,
set_version_middleware,
))
.route_layer(middleware::from_fn_with_state(
state.version,
check_version_middleware,
))
.layer(axum::extract::Extension(schema))
.layer(axum::extract::Extension(watermark_task.lock()))
.layer(axum::extract::Extension(watermark_task.chain_id_lock()))
Expand Down
Loading
Loading