Skip to content

Commit

Permalink
Sometimes all you need is a good rubber duck
Browse files Browse the repository at this point in the history
  • Loading branch information
deekerno committed Dec 8, 2023
1 parent 0367eca commit 4834ac9
Show file tree
Hide file tree
Showing 4 changed files with 277 additions and 248 deletions.
1 change: 1 addition & 0 deletions packages/fuel-indexer-graphql/src/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ impl QueryParams {
query_clause
}

// TODO: Allow for non-id field to be used for pagination.
pub(crate) fn parse_pagination(&mut self, db_type: &DbType) {
match db_type {
DbType::Postgres => {
Expand Down
5 changes: 3 additions & 2 deletions packages/fuel-indexer-graphql/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ pub enum GraphqlError {
}

#[derive(Debug, Clone)]
pub enum ParsedQueryKind {
pub enum QueryKind {
Object,
Connection,
Cte,
}

/// The type of selection that can be present in a user's operation.
Expand Down Expand Up @@ -86,7 +87,7 @@ pub enum ParsedSelection {
alias: Option<Positioned<Name>>,
fields: Vec<ParsedSelection>,
arguments: Vec<ParamType>,
kind: ParsedQueryKind,
kind: QueryKind,
root_entity_type: String,
},
PageInfo {
Expand Down
11 changes: 4 additions & 7 deletions packages/fuel-indexer-graphql/src/query/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use fuel_indexer_lib::graphql::{parser::InternalType, ParsedGraphQLSchema};

use crate::{
arguments::{parse_argument_into_param, ParamType},
GraphqlError, GraphqlResult, ParsedQueryKind, ParsedSelection,
GraphqlError, GraphqlResult, ParsedSelection, QueryKind,
};

/// Contains information about a successfully-parsed user operation.
Expand Down Expand Up @@ -265,15 +265,12 @@ fn parse_selections(
Some(&query_type),
)?;
let (kind, query_type) = if query_type.contains("Connection") {
(
ParsedQueryKind::Connection,
query_type.replace("Connection", ""),
)
(QueryKind::Connection, query_type.replace("Connection", ""))
} else {
(ParsedQueryKind::Object, query_type)
(QueryKind::Object, query_type)
};

if let ParsedQueryKind::Object = kind {
if let QueryKind::Object = kind {
if !arguments.iter().any(|a| {
matches!(
a,
Expand Down
Loading

0 comments on commit 4834ac9

Please sign in to comment.