-
Notifications
You must be signed in to change notification settings - Fork 11.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[graphql][feature][breaking] compound type filter on ObjectFilter (#1…
…5200) ## Description Today we have a cascading filter of package, module, and ty on the ObjectFilter. This PR combines the three fields into 1, and adds logic to handle looking up generic types. Now, callers can provide 1. primitive like u64 2. just the package, 0x2 3. package and module: 0x2::coin 4. package, module, type: 0x2::coin::Coin 5. fully instantiated type: 0x2::coin::Coin<0x2::sui::SUI> ## Test Plan New filter_by_type.move --- If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process. ### Type of Change (Check all that apply) - [ ] protocol change - [ ] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes
- Loading branch information
Showing
10 changed files
with
797 additions
and
22 deletions.
There are no files selected for viewing
450 changes: 450 additions & 0 deletions
450
crates/sui-graphql-e2e-tests/tests/objects/filter_by_type.exp
Large diffs are not rendered by default.
Oops, something went wrong.
196 changes: 196 additions & 0 deletions
196
crates/sui-graphql-e2e-tests/tests/objects/filter_by_type.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//# init --simulator --accounts C | ||
|
||
// TODO: Short term hack to get around indexer epoch issue | ||
//# create-checkpoint | ||
|
||
//# advance-epoch | ||
|
||
//# programmable --sender C --inputs 10000000000 @C | ||
//> SplitCoins(Gas, [Input(0)]); | ||
//> TransferObjects([Result(0)], Input(1)) | ||
|
||
//# run 0x3::sui_system::request_add_stake --args object(0x5) object(3,0) @validator_0 --sender C | ||
|
||
// TODO: Short term hack to get around indexer epoch issue | ||
//# create-checkpoint | ||
|
||
//# advance-epoch | ||
|
||
//# run-graphql | ||
{ | ||
objectConnection(filter: {type: "0x3::staking_pool::StakedSui"}) { | ||
edges { | ||
node { | ||
asMoveObject { | ||
contents { | ||
type { | ||
repr | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
//# run-graphql | ||
{ | ||
objectConnection(filter: {type: "0x2"}) { | ||
edges { | ||
node { | ||
asMoveObject { | ||
contents { | ||
type { | ||
repr | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
//# run-graphql | ||
{ | ||
objectConnection(filter: {type: "0x2::coin"}) { | ||
edges { | ||
node { | ||
asMoveObject { | ||
contents { | ||
type { | ||
repr | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
//# run-graphql | ||
{ | ||
objectConnection(filter: {type: "0x2::coin::Coin"}) { | ||
edges { | ||
node { | ||
asMoveObject { | ||
contents { | ||
type { | ||
repr | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
//# run-graphql | ||
# Fetch coins of 0x2::sui::SUI inner type | ||
{ | ||
objectConnection(filter: {type: "0x2::coin::Coin<0x2::sui::SUI>"}) { | ||
edges { | ||
node { | ||
asMoveObject { | ||
contents { | ||
type { | ||
repr | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
//# run-graphql | ||
# Inner type should be fully qualified | ||
{ | ||
objectConnection(filter: {type: "0x2::coin::Coin<ye>"}) { | ||
edges { | ||
node { | ||
asMoveObject { | ||
contents { | ||
type { | ||
repr | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
//# run-graphql | ||
# If caller provides angle brackets, they must be balanced and wrap a valid type | ||
{ | ||
objectConnection(filter: {type: "0x2::coin::Coin<"}) { | ||
edges { | ||
node { | ||
asMoveObject { | ||
contents { | ||
type { | ||
repr | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
//# run-graphql | ||
# Package, module, and name must be valid addresses and identifiers | ||
{ | ||
objectConnection(filter: {type: "0x2::a%::B&"}) { | ||
edges { | ||
node { | ||
asMoveObject { | ||
contents { | ||
type { | ||
repr | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
//# run-graphql | ||
# Empty strings are invalid inputs | ||
{ | ||
objectConnection(filter: {type: "::::"}) { | ||
edges { | ||
node { | ||
asMoveObject { | ||
contents { | ||
type { | ||
repr | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
//# run-graphql | ||
# Should run successfully but return an empty result | ||
{ | ||
objectConnection(filter: {type: "u64"}) { | ||
edges { | ||
node { | ||
asMoveObject { | ||
contents { | ||
type { | ||
repr | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
crates/sui-graphql-rpc/examples/object_connection/filter_on_generic_type.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
objectConnection(filter: {type: "0x2::coin::Coin"}) { | ||
edges { | ||
node { | ||
asMoveObject { | ||
contents { | ||
type { | ||
repr | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
crates/sui-graphql-rpc/examples/object_connection/filter_on_type.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
objectConnection(filter: {type: "0x3::staking_pool::StakedSui"}) { | ||
edges { | ||
node { | ||
asMoveObject { | ||
contents { | ||
type { | ||
repr | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
54c9ecd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
sui-typescript-docs – ./sdk/docs
sui-typescript-docs-git-main-mysten-labs.vercel.app
sui-wallet-kit.vercel.app
sui-typescript-docs.vercel.app
sui-typescript-docs-mysten-labs.vercel.app
54c9ecd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
sui-core – ./docs/site
sui-core-git-main-sui-foundation.vercel.app
sui-core.vercel.app
www.docs.sui.io
sui-core-sui-foundation.vercel.app
docs.sui.io
54c9ecd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
mysten-ui – ./apps/ui
mysten-ui-mysten-labs.vercel.app
mysten-ui-git-main-mysten-labs.vercel.app
mysten-ui.vercel.app