Skip to content

Commit 3464657

Browse files
Merge branch 'master' into feature/separate-input-schemas
2 parents c5d1d77 + a17541e commit 3464657

9 files changed

Lines changed: 236 additions & 1192 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/schema.gql

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ type AddData {
409409
Last offset of the previous data slice, if any. Must be equal to the
410410
last non-empty `newData.offsetInterval.end`.
411411
"""
412-
prevOffset: Int
412+
prevOffset: Uint64
413413
"""
414414
Describes output data written during this transaction, if any.
415415
"""
@@ -610,7 +610,7 @@ type Checkpoint {
610610
"""
611611
Size of checkpoint file in bytes.
612612
"""
613-
size: Int!
613+
size: Uint64!
614614
}
615615

616616
type CliProtocolDesc {
@@ -1070,7 +1070,7 @@ type DataSlice {
10701070
"""
10711071
Size of data file in bytes.
10721072
"""
1073-
size: Int!
1073+
size: Uint64!
10741074
}
10751075

10761076
input DataTypeInput {
@@ -1986,7 +1986,7 @@ type ExecuteTransform {
19861986
Last offset of the previous data slice, if any. Must be equal to the
19871987
last non-empty `newData.offsetInterval.end`.
19881988
"""
1989-
prevOffset: Int
1989+
prevOffset: Uint64
19901990
"""
19911991
Describes output data written during this transaction, if any.
19921992
"""
@@ -2039,14 +2039,14 @@ type ExecuteTransformInput {
20392039
half-open `(prevOffset, newOffset]` interval of data records that will
20402040
be considered in this transaction.
20412041
"""
2042-
prevOffset: Int
2042+
prevOffset: Uint64
20432043
"""
20442044
Offset of the last data record that will be incorporated into the
20452045
derivative transformation, if any. When present, defines a half-open
20462046
`(prevOffset, newOffset]` interval of data records that will be
20472047
considered in this transaction.
20482048
"""
2049-
newOffset: Int
2049+
newOffset: Uint64
20502050
}
20512051

20522052
scalar ExtraAttributes
@@ -2097,7 +2097,7 @@ type FetchStepEthereumLogs {
20972097
for RPC endpoint lookup as well as asserting that provided `nodeUrl`
20982098
corresponds to the expected chain.
20992099
"""
2100-
chainId: Int
2100+
chainId: Uint64
21012101
"""
21022102
Url of the node.
21032103
"""
@@ -3261,11 +3261,11 @@ type OffsetInterval {
32613261
"""
32623262
Start of the closed interval [start; end].
32633263
"""
3264-
start: Int!
3264+
start: Uint64!
32653265
"""
32663266
End of the closed interval [start; end].
32673267
"""
3268-
end: Int!
3268+
end: Uint64!
32693269
}
32703270

32713271
enum OrderingDirection {
@@ -4355,6 +4355,8 @@ type TriggerFlowSuccess implements TriggerFlowResult {
43554355

43564356
scalar URL
43574357

4358+
scalar Uint64
4359+
43584360
interface UnsetRoleResult {
43594361
message: String!
43604362
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright Kamu Data, Inc. and contributors. All rights reserved.
2+
//
3+
// Use of this software is governed by the Business Source License
4+
// included in the LICENSE file.
5+
//
6+
// As of the Change Date specified in that file, in accordance with
7+
// the Business Source License, use of this software will be governed
8+
// by the Apache License, Version 2.0.
9+
10+
use async_graphql::{InputValueError, InputValueResult, Scalar, ScalarType, Value};
11+
12+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
13+
14+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
15+
pub struct UInt64(pub u64);
16+
17+
impl From<u64> for UInt64 {
18+
fn from(value: u64) -> Self {
19+
Self(value)
20+
}
21+
}
22+
23+
impl From<UInt64> for u64 {
24+
fn from(value: UInt64) -> Self {
25+
value.0
26+
}
27+
}
28+
29+
#[Scalar]
30+
impl ScalarType for UInt64 {
31+
fn parse(value: Value) -> InputValueResult<Self> {
32+
match value {
33+
Value::String(s) => {
34+
let val = s
35+
.parse::<u64>()
36+
.map_err(|e| InputValueError::custom(format!("Invalid UInt64: {e}")))?;
37+
Ok(Self(val))
38+
}
39+
Value::Number(n) => {
40+
let n = n.to_string();
41+
42+
Err(InputValueError::custom(format!(
43+
"Invalid UInt64: the value is expected to be a string (\"{n}\") instead of a \
44+
number ({n})"
45+
)))
46+
}
47+
v @ (Value::Null
48+
| Value::Boolean(_)
49+
| Value::Binary(_)
50+
| Value::Enum(_)
51+
| Value::List(_)
52+
| Value::Object(_)) => Err(InputValueError::expected_type(v)),
53+
}
54+
}
55+
56+
fn to_value(&self) -> Value {
57+
Value::String(self.0.to_string())
58+
}
59+
}
60+
61+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

src/adapter/graphql/src/scalars/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl MetadataBlockExtended {
5151
system_time: block.system_time,
5252
author,
5353
event: block.event,
54-
sequence_number: block.sequence_number,
54+
sequence_number: block.sequence_number.into(),
5555
block: original_block,
5656
})
5757
}

src/adapter/graphql/src/scalars/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ mod flow_retry_policy;
3737
mod flow_scalars;
3838
mod flow_trigger;
3939
mod gql_url;
40+
mod int64;
4041
mod key_value;
4142
mod metadata;
4243
mod multihash;
@@ -80,6 +81,7 @@ pub use flow_retry_policy::*;
8081
pub use flow_scalars::{TimeUnit, *};
8182
pub use flow_trigger::{FlowTrigger, *};
8283
pub use gql_url::*;
84+
pub use int64::*;
8385
pub use key_value::*;
8486
pub use metadata::*;
8587
pub use multihash::*;

0 commit comments

Comments
 (0)