Skip to content

Commit

Permalink
[GraphQL/Schema][chore] Sync draft schema with current (MystenLabs#15252
Browse files Browse the repository at this point in the history
)

## Description

The draft schema and real schema diverged quite a bit while we added new
features and responded to feedback. It was becoming unclear which
differences were because we responded to feedback directly in the
implementation, and which ones were features we need to implement from
the draft.

This PR brings it back in line so that the draft schema can once again
act as a source of truth:

### Changes to actual schema

- Ported over doc comments from the draft schema
- Made some fields non-nullable to match schema (`OpenMoveType`,
mainly).
- Made `ServiceConfig` limit fields all `Int` rather than `BigInt`
(these limits won't be over 2^53).

### Changes to draft schema

- Changes to execution APIs to reflect recent discussions with @oxade
(dry-run API doesn't accept an epoch parameter, accepts gas objects by
ObjectRef rather than just by ID, and also accepts a gas budget).
- Tweaked some type names to match how they look in the actual schema
(e.g. `CheckpointID` -> `CheckpointId`).
- Connection fields lose the `Connection` suffix on their field names,
and are guaranteed to return a non-null `Connection`. The `Connection`
types all gain a `nodes` field (like `edges` but without cursors).
- Update type/function filters to be a single string that can accept
multiple different formats, rather than three separte fields.
- Make fields non-nullable according to actual implementation.
- Added `dynamicObjectFields` API (added during implementation phase).
- Updated all TransactionKind types in draft to match impl in MystenLabs#15211
- Remove `hasPublicTransfer` to reflect MystenLabs#15220.
- Updated interface for `ObjectOwner` / `ObjectKind` so that we can
share the initial shared version for a shared object.
- Made the `DateTime`s that should be non-null, non-null.
- Lists generally contain non-null elements.
- TransactionBlocks have only one `sender`, not multiple (for now). Same
for events.
- Everything that should be a connection rather than an array, is.
- Rename `objectReads` to `unchangedSharedObjects` in
`TransactionBlockEffects` to reflect a similar naming (and semantic)
change in `TransactionEffectsV2`.

## Test Plan

```
sui-graphql-rpc$ cargo nextest run
sui-graphql-e2e-tests$ cargo nextest run \
  -j 1 --features pg_integration
```
  • Loading branch information
amnn authored Dec 7, 2023
1 parent 489bc78 commit 1448bbe
Show file tree
Hide file tree
Showing 12 changed files with 576 additions and 254 deletions.
70 changes: 52 additions & 18 deletions crates/sui-graphql-rpc/schema/current_progress_schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ type BalanceEdge {

scalar Base64

"""
String representation of an arbitrary width, possibly signed integer.
"""
scalar BigInt


Expand Down Expand Up @@ -332,6 +335,9 @@ type CheckpointEdge {
cursor: String!
}

"""
Filter either by the digest, or the sequence number, or neither, to get the latest checkpoint.
"""
input CheckpointId {
digest: String
sequenceNumber: Int
Expand Down Expand Up @@ -434,6 +440,9 @@ type ConsensusCommitPrologueTransaction {
consensusCommitDigest: String
}

"""
ISO-8601 Date and Time: RFC3339 in UTC with format: YYYY-MM-DDTHH:MM:SS.mmmZ
"""
scalar DateTime

type DynamicField {
Expand Down Expand Up @@ -685,18 +694,14 @@ input EventFilter {
sender: SuiAddress
transactionDigest: String
"""
Events emitted by a particular package.
An event is emitted by a particular package
if some function in the package is called
by a PTB and emits an event.
Events emitted by a particular package. An event is emitted by a particular package if some
function in the package is called by a PTB and emits an event.
"""
emittingPackage: SuiAddress
"""
Events emitted by a particular Move module.
An event is emitted by a particular module
if some function in the module is called
by a PTB and emits an event.
Requires `emitting_package` to be set.
Events emitted by a particular Move module. An event is emitted by a particular module if
some function in the module is called by a PTB and emits an event. Requires
`emitting_package` to be set.
"""
emittingModule: String
eventPackage: SuiAddress
Expand Down Expand Up @@ -1480,14 +1485,26 @@ type ObjectEdge {

input ObjectFilter {
"""
This field is used to specify the type of objects that should be included
in the query results. Generic types can be queried by either the generic
type name, e.g. `0x2::coin::Coin`, or by the full type name, such as
`0x2::coin::Coin<0x2::sui::SUI>`.
This field is used to specify the type of objects that should be include in the query
results.
Type can be filtered by their package, package::module, or their fuly qualified type name.
Generic types can be queried by either the generic type name, e.g. `0x2::coin::Coin`, or by
the full type name, such as `0x2::coin::Coin<0x2::sui::SUI>`.
"""
type: String
"""
Filter for live objects by their current owners.
"""
owner: SuiAddress
"""
Filter for live objects by their IDs.
"""
objectIds: [SuiAddress!]
"""
Filter for live or potentially historical objects by their ID and version.
"""
objectKeys: [ObjectKey!]
}

Expand Down Expand Up @@ -1524,11 +1541,11 @@ type OpenMoveType {
"""
Structured representation of the type signature.
"""
signature: OpenMoveTypeSignature
signature: OpenMoveTypeSignature!
"""
Flat representation of the type signature, as a displayable string.
"""
repr: String
repr: String!
}

"""
Expand Down Expand Up @@ -1772,8 +1789,18 @@ type Query {
owner(address: SuiAddress!): ObjectOwner
object(address: SuiAddress!, version: Int): Object
address(address: SuiAddress!): Address
"""
Fetch epoch information by ID (defaults to the latest epoch).
"""
epoch(id: Int): Epoch
"""
Fetch checkpoint information by sequence number or digest (defaults to the latest available
checkpoint).
"""
checkpoint(id: CheckpointId): Checkpoint
"""
Fetch a transaction block by its transaction digest.
"""
transactionBlock(digest: String!): TransactionBlock
"""
The coin objects that exist in the network.
Expand All @@ -1786,6 +1813,10 @@ type Query {
transactionBlockConnection(first: Int, after: String, last: Int, before: String, filter: TransactionBlockFilter): TransactionBlockConnection
eventConnection(first: Int, after: String, last: Int, before: String, filter: EventFilter): EventConnection
objectConnection(first: Int, after: String, last: Int, before: String, filter: ObjectFilter): ObjectConnection
"""
Fetch the protocl config by protocol version (defaults to the latest protocol
version known to the GraphQL)
"""
protocolConfig(protocolVersion: Int): ProtocolConfigs!
"""
Resolves the owner address of the provided domain name
Expand Down Expand Up @@ -1890,15 +1921,15 @@ type ServiceConfig {
"""
Default number of elements allowed on a single page of a connection.
"""
defaultPageSize: BigInt!
defaultPageSize: Int!
"""
Maximum number of elements allowed on a single page of a connection.
"""
maxPageSize: BigInt!
maxPageSize: Int!
"""
Maximum time in milliseconds that will be spent to serve one request.
"""
requestTimeoutMs: BigInt!
requestTimeoutMs: Int!
"""
Maximum length of a query payload string.
"""
Expand Down Expand Up @@ -2065,6 +2096,9 @@ type StorageFund {
}


"""
String containing 32B hex-encoded address, with a leading "0x". Leading zeroes can be omitted on input but will always appear in outputs (SuiAddress in output is guaranteed to be 66 characters long).
"""
scalar SuiAddress

"""
Expand Down
Loading

0 comments on commit 1448bbe

Please sign in to comment.