Skip to content

Commit

Permalink
[GraphQL/MovePackage] Query by ID and version
Browse files Browse the repository at this point in the history
## Description

Implement `Query.package` and `MovePackage.atVersion` to query a
package at a specific version, using the new fields added to the
`packages` table, exposed via some new data loaders.

## Test plan

New transactional tests:

```
sui$ cargo nextest run -p sui-graphql-e2e-tests \
  --features pg_integration                     \
  -- packages/versioning
```
  • Loading branch information
amnn committed May 14, 2024
1 parent bd68455 commit 5751ce4
Show file tree
Hide file tree
Showing 9 changed files with 714 additions and 28 deletions.
310 changes: 310 additions & 0 deletions crates/sui-graphql-e2e-tests/tests/packages/versioning.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,310 @@
processed 9 tasks

init:
A: object(0,0)

task 1 'publish'. lines 6-9:
created: object(1,0), object(1,1)
mutated: object(0,0)
gas summary: computation_cost: 1000000, storage_cost: 5076800, storage_rebate: 0, non_refundable_storage_fee: 0

task 2 'upgrade'. lines 11-15:
created: object(2,0)
mutated: object(0,0), object(1,1)
gas summary: computation_cost: 1000000, storage_cost: 5251600, storage_rebate: 2595780, non_refundable_storage_fee: 26220

task 3 'upgrade'. lines 17-22:
created: object(3,0)
mutated: object(0,0), object(1,1)
gas summary: computation_cost: 1000000, storage_cost: 5426400, storage_rebate: 2595780, non_refundable_storage_fee: 26220

task 4 'create-checkpoint'. lines 24-24:
Checkpoint created: 1

task 5 'run-graphql'. lines 26-45:
Response: {
"data": {
"v1": {
"module": {
"functions": {
"nodes": [
{
"name": "f"
}
]
}
}
},
"v2": {
"module": {
"functions": {
"nodes": [
{
"name": "f"
},
{
"name": "g"
}
]
}
}
},
"v3": {
"module": {
"functions": {
"nodes": [
{
"name": "f"
},
{
"name": "g"
},
{
"name": "h"
}
]
}
}
}
}
}

task 6 'run-graphql'. lines 47-84:
Response: {
"data": {
"v1_from_p1": {
"module": {
"functions": {
"nodes": [
{
"name": "f"
}
]
}
}
},
"v1_from_p2": {
"module": {
"functions": {
"nodes": [
{
"name": "f"
}
]
}
}
},
"v2_from_p0": {
"module": {
"functions": {
"nodes": [
{
"name": "f"
},
{
"name": "g"
}
]
}
}
},
"v2_from_p2": {
"module": {
"functions": {
"nodes": [
{
"name": "f"
},
{
"name": "g"
}
]
}
}
},
"v3_from_p0": {
"module": {
"functions": {
"nodes": [
{
"name": "f"
},
{
"name": "g"
},
{
"name": "h"
}
]
}
}
},
"v3_from_p1": {
"module": {
"functions": {
"nodes": [
{
"name": "f"
},
{
"name": "g"
},
{
"name": "h"
}
]
}
}
}
}
}

task 7 'run-graphql'. lines 86-141:
Response: {
"data": {
"v1": {
"v1": {
"module": {
"functions": {
"nodes": [
{
"name": "f"
}
]
}
}
},
"v2": {
"module": {
"functions": {
"nodes": [
{
"name": "f"
},
{
"name": "g"
}
]
}
}
},
"v3": {
"module": {
"functions": {
"nodes": [
{
"name": "f"
},
{
"name": "g"
},
{
"name": "h"
}
]
}
}
}
},
"v2": {
"v1": {
"module": {
"functions": {
"nodes": [
{
"name": "f"
}
]
}
}
},
"v2": {
"module": {
"functions": {
"nodes": [
{
"name": "f"
},
{
"name": "g"
}
]
}
}
},
"v3": {
"module": {
"functions": {
"nodes": [
{
"name": "f"
},
{
"name": "g"
},
{
"name": "h"
}
]
}
}
}
},
"v3": {
"v1": {
"module": {
"functions": {
"nodes": [
{
"name": "f"
}
]
}
}
},
"v2": {
"module": {
"functions": {
"nodes": [
{
"name": "f"
},
{
"name": "g"
}
]
}
}
},
"v3": {
"module": {
"functions": {
"nodes": [
{
"name": "f"
},
{
"name": "g"
},
{
"name": "h"
}
]
}
}
}
}
}
}

task 8 'run-graphql'. lines 143-171:
Response: {
"data": {
"v0": null,
"v1": {
"v0": null,
"v4": null
},
"v4": null
}
}
Loading

0 comments on commit 5751ce4

Please sign in to comment.