Skip to content
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
30 changes: 11 additions & 19 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ graph-store-postgres = { path = "./store/postgres" }
graphman-server = { path = "./server/graphman" }
graphman = { path = "./core/graphman" }
graphman-store = { path = "./core/graphman_store" }
graphql-tools = "0.5.0"
itertools = "0.14.0"
lazy_static = "1.5.0"
prost = "0.13"
Expand Down
2 changes: 1 addition & 1 deletion graph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ http-body-util = "0.1"
hyper-util = { version = "0.1", features = ["full"] }
futures01 = { package = "futures", version = "0.1.31" }
lru_time_cache = "0.11"
graphql-parser = "0.4.1"
graphql-tools = { workspace = true }
lazy_static = "1.5.0"
num-bigint = { version = "=0.2.6", features = ["serde"] }
num-integer = { version = "=0.1.46" }
Expand Down
7 changes: 3 additions & 4 deletions graph/examples/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use graph::data::subgraph::SPEC_VERSION_1_1_0;
use graph::prelude::s;
use graph::prelude::DeploymentHash;
use graph::schema::InputSchema;
use graphql_parser::parse_schema;
use serde::Deserialize;
use std::alloc::GlobalAlloc;
use std::alloc::Layout;
Expand Down Expand Up @@ -147,7 +146,7 @@ struct Opts {
#[clap(long)]
api: bool,
#[clap(
short, long, default_value = "validate",
short, long, default_value = "validate",
value_parser = clap::builder::PossibleValuesParser::new(&["validate", "size"])
)]
mode: RunMode,
Expand All @@ -157,7 +156,7 @@ struct Opts {
}

fn parse(raw: &str, name: &str, api: bool) -> Result<DeploymentHash> {
let schema = parse_schema(raw)
let schema = s::parse_schema(raw)
.map(|v| v.into_static())
.map_err(|e| anyhow!("Failed to parse schema sgd{name}: {e}"))?;
let id = subgraph_id(&schema);
Expand Down Expand Up @@ -233,7 +232,7 @@ impl Sizer {
let elapsed = start.elapsed();
let txt_size = raw.len();
let (gql_size, _) = self.size(|| {
parse_schema(raw)
s::parse_schema(raw)
.map(|v| v.into_static())
.map_err(Into::into)
})?;
Expand Down
6 changes: 2 additions & 4 deletions graph/src/data/graphql/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,6 @@ impl FieldExt for Field {

#[cfg(test)]
mod directive_finder_tests {
use graphql_parser::parse_schema;

use super::*;

const SCHEMA: &str = "
Expand All @@ -407,7 +405,7 @@ mod directive_finder_tests {
/// Makes sure that the DirectiveFinder::find_directive implementation for ObjectiveType and Field works
#[test]
fn find_directive_impls() {
let ast = parse_schema::<String>(SCHEMA).unwrap();
let ast = s::parse_schema::<String>(SCHEMA).unwrap();
let object_types = ast.get_object_type_definitions();
assert_eq!(object_types.len(), 1);
let object_type = object_types[0];
Expand All @@ -430,7 +428,7 @@ mod directive_finder_tests {
/// Makes sure that the DirectiveFinder::is_derived implementation for ObjectiveType and Field works
#[test]
fn is_derived_impls() {
let ast = parse_schema::<String>(SCHEMA).unwrap();
let ast = s::parse_schema::<String>(SCHEMA).unwrap();
let object_types = ast.get_object_type_definitions();
assert_eq!(object_types.len(), 1);
let object_type = object_types[0];
Expand Down
15 changes: 7 additions & 8 deletions graph/src/data/graphql/shape_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl ShapeHash for q::Document {

impl ShapeHash for q::OperationDefinition {
fn shape_hash(&self, hasher: &mut ShapeHasher) {
use graphql_parser::query::OperationDefinition::*;
use graphql_tools::parser::query::OperationDefinition::*;
// We want `[query|subscription|mutation] things { BODY }` to hash
// to the same thing as just `things { BODY }`
match self {
Expand Down Expand Up @@ -69,7 +69,7 @@ impl ShapeHash for q::SelectionSet {

impl ShapeHash for q::Selection {
fn shape_hash(&self, hasher: &mut ShapeHasher) {
use graphql_parser::query::Selection::*;
use graphql_tools::parser::query::Selection::*;
match self {
Field(field) => field.shape_hash(hasher),
FragmentSpread(spread) => spread.shape_hash(hasher),
Expand All @@ -92,7 +92,7 @@ impl ShapeHash for q::Field {

impl ShapeHash for s::Value {
fn shape_hash(&self, hasher: &mut ShapeHasher) {
use graphql_parser::schema::Value::*;
use graphql_tools::parser::schema::Value::*;

match self {
Variable(_) | Int(_) | Float(_) | String(_) | Boolean(_) | Null | Enum(_) => {
Expand Down Expand Up @@ -151,24 +151,23 @@ impl ShapeHash for q::TypeCondition {
#[cfg(test)]
mod tests {
use super::*;
use graphql_parser::parse_query;

#[test]
fn identical_and_different() {
const Q1: &str = "query things($stuff: Int) { things(where: { stuff_gt: $stuff }) { id } }";
const Q2: &str = "{ things(where: { stuff_gt: 42 }) { id } }";
const Q3: &str = "{ things(where: { stuff_lte: 42 }) { id } }";
const Q4: &str = "{ things(where: { stuff_gt: 42 }) { id name } }";
let q1 = parse_query(Q1)
let q1 = q::parse_query(Q1)
.expect("q1 is syntactically valid")
.into_static();
let q2 = parse_query(Q2)
let q2 = q::parse_query(Q2)
.expect("q2 is syntactically valid")
.into_static();
let q3 = parse_query(Q3)
let q3 = q::parse_query(Q3)
.expect("q3 is syntactically valid")
.into_static();
let q4 = parse_query(Q4)
let q4 = q::parse_query(Q4)
.expect("q4 is syntactically valid")
.into_static();

Expand Down
23 changes: 11 additions & 12 deletions graph/src/data/query/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use graphql_parser::Pos;
use hex::FromHexError;
use serde::ser::*;
use std::collections::HashMap;
Expand Down Expand Up @@ -26,20 +25,20 @@ pub enum QueryExecutionError {
OperationNameRequired,
OperationNotFound(String),
NotSupported(String),
NonNullError(Pos, String),
ListValueError(Pos, String),
NonNullError(q::Pos, String),
ListValueError(q::Pos, String),
NamedTypeError(String),
AbstractTypeError(String),
InvalidArgumentError(Pos, String, q::Value),
MissingArgumentError(Pos, String),
ValidationError(Option<Pos>, String),
InvalidVariableTypeError(Pos, String),
MissingVariableError(Pos, String),
InvalidArgumentError(q::Pos, String, q::Value),
MissingArgumentError(q::Pos, String),
ValidationError(Option<q::Pos>, String),
InvalidVariableTypeError(q::Pos, String),
MissingVariableError(q::Pos, String),
ResolveEntitiesError(String),
OrderByNotSupportedError(String, String),
OrderByNotSupportedForType(String),
FilterNotSupportedError(String, String),
UnknownField(Pos, String, String),
UnknownField(q::Pos, String, String),
EmptyQuery,
InvalidOrFilterStructure(Vec<String>, String),
SubgraphDeploymentIdError(String),
Expand All @@ -55,10 +54,10 @@ pub enum QueryExecutionError {
StoreError(CloneableAnyhowError),
Timeout,
EmptySelectionSet(String),
AmbiguousDerivedFromResult(Pos, String, String, String),
AmbiguousDerivedFromResult(q::Pos, String, String, String),
Unimplemented(String),
EnumCoercionError(Pos, String, q::Value, String, Vec<String>),
ScalarCoercionError(Pos, String, q::Value, String),
EnumCoercionError(q::Pos, String, q::Value, String, Vec<String>),
ScalarCoercionError(q::Pos, String, q::Value, String),
TooComplex(u64, u64), // (complexity, max_complexity)
TooDeep(u8), // max_depth
CyclicalFragment(String),
Expand Down
2 changes: 1 addition & 1 deletion graph/src/data/query/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl Query {
{
(
document
.format(graphql_parser::Style::default().indent(0))
.format(graphql_tools::parser::Style::default().indent(0))
.replace('\n', " "),
serde_json::to_string(&variables).unwrap_or_default(),
)
Expand Down
2 changes: 1 addition & 1 deletion graph/src/data/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ impl NullValue for Value {

impl Value {
pub fn from_query_value(value: &r::Value, ty: &s::Type) -> Result<Value, QueryExecutionError> {
use graphql_parser::schema::Type::{ListType, NamedType, NonNullType};
use graphql_tools::parser::schema::Type::{ListType, NamedType, NonNullType};

Ok(match (value, ty) {
// When dealing with non-null types, use the inner type to convert the value
Expand Down
33 changes: 18 additions & 15 deletions graph/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,31 +176,34 @@ pub mod prelude {

macro_rules! static_graphql {
($m:ident, $m2:ident, {$($n:ident,)*}) => {
pub mod $m {
use graphql_parser::$m2 as $m;
pub use graphql_parser::Pos;
use graphql_tools::parser::$m2 as $m;
pub use graphql_tools::parser::Pos;
pub use $m::*;
$(
pub type $n = $m::$n<'static, String>;
)*
}
};
}

// Static graphql mods. These are to be phased out, with a preference
// toward making graphql generic over text. This helps to ease the
// transition by providing the old graphql-parse 0.2.x API
static_graphql!(q, query, {
Document, Value, OperationDefinition, InlineFragment, TypeCondition,
FragmentSpread, Field, Selection, SelectionSet, FragmentDefinition,
Directive, VariableDefinition, Type, Query,
});
static_graphql!(s, schema, {
Field, Directive, InterfaceType, ObjectType, Value, TypeDefinition,
EnumType, Type, Definition, Document, ScalarType, InputValue, DirectiveDefinition,
UnionType, InputObjectType, EnumValue,
});

pub mod q {
static_graphql!(q, query, {
Document, Value, OperationDefinition, InlineFragment, TypeCondition,
FragmentSpread, Field, Selection, SelectionSet, FragmentDefinition,
Directive, VariableDefinition, Type, Query,
});
pub use q::parse_query;
}
pub mod s {
static_graphql!(s, schema, {
Field, Directive, InterfaceType, ObjectType, Value, TypeDefinition,
EnumType, Type, Definition, Document, ScalarType, InputValue, DirectiveDefinition,
UnionType, InputObjectType, EnumValue,
});
pub use s::parse_schema;
}
pub mod r {
pub use crate::data::value::{Object, Value};
}
Expand Down
Loading