Skip to content

Commit

Permalink
Remove nested contract resolvers in GQL schema (FuelLabs#1675)
Browse files Browse the repository at this point in the history
closes: FuelLabs#1652

Having the ability to fetch all data related to a contract is overkill
and costly in most cases, and usually done by accident. This api change
simplifies the GQL schema to simply return a contractId instead of a
contract resolver for tx inputs, receipts, and more.

Note that the full contract details (such as the contract bytecode) can
still be fetched directly via the contract query endpoint.
  • Loading branch information
Voxelot authored Feb 18, 2024
1 parent 5871ef2 commit a838222
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 142 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Description of the upcoming release here.
- [#1636](https://github.com/FuelLabs/fuel-core/pull/1636): Add more docs to GraphQL DAP API.

#### Breaking
- [#1675](https://github.com/FuelLabs/fuel-core/pull/1675): Simplify GQL schema by disabling contract resolvers in most cases, and just return a ContractId scalar instead.
- [#1658](https://github.com/FuelLabs/fuel-core/pull/1658): Receipts are part of the transaction status.
Removed `reason` from the `TransactionExecutionResult::Failed`. It can be calculated based on the program state and receipts.
Also, it is not possible to fetch `receipts` from the `Transaction` directly anymore. Instead, you need to fetch `status` and its receipts.
Expand Down
13 changes: 8 additions & 5 deletions crates/client/assets/schema.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ input ContractBalanceFilterInput {
}

type ContractCreated {
contract: Contract!
contract: ContractId!
stateRoot: Bytes32!
}

Expand Down Expand Up @@ -508,7 +508,7 @@ type InputContract {
balanceRoot: Bytes32!
stateRoot: Bytes32!
txPointer: TxPointer!
contract: Contract!
contractId: ContractId!
}

type InputMessage {
Expand Down Expand Up @@ -826,10 +826,10 @@ type Query {
}

type Receipt {
contract: Contract
id: ContractId
pc: U64
is: U64
to: Contract
to: ContractId
toAddress: Address
amount: U64
assetId: AssetId
Expand All @@ -852,6 +852,9 @@ type Receipt {
sender: Address
recipient: Address
nonce: Nonce
"""
Set in the case of a Panic receipt to indicate a missing contract input id
"""
contractId: ContractId
subId: Bytes32
}
Expand Down Expand Up @@ -957,7 +960,7 @@ scalar Tai64Timestamp
type Transaction {
id: TransactionId!
inputAssetIds: [AssetId!]
inputContracts: [Contract!]
inputContracts: [ContractId!]
inputContract: InputContract
policies: Policies
gasPrice: U64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ mutation($txs: [HexString!]!, $utxoValidation: Boolean) {
assetId
gas
digest
contract {
id
}
id
is
pc
ptr
Expand All @@ -31,9 +29,7 @@ mutation($txs: [HexString!]!, $utxoValidation: Boolean) {
rd
reason
receiptType
to {
id
}
to
toAddress
val
len
Expand All @@ -59,9 +55,7 @@ mutation($txs: [HexString!]!, $utxoValidation: Boolean) {
assetId
gas
digest
contract {
id
}
id
is
pc
ptr
Expand All @@ -71,9 +65,7 @@ mutation($txs: [HexString!]!, $utxoValidation: Boolean) {
rd
reason
receiptType
to {
id
}
to
toAddress
val
len
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ query($id: TransactionId!) {
assetId
gas
digest
contract {
id
}
id
is
pc
ptr
Expand All @@ -39,9 +37,7 @@ query($id: TransactionId!) {
rd
reason
receiptType
to {
id
}
to
toAddress
val
len
Expand Down Expand Up @@ -76,9 +72,7 @@ query($id: TransactionId!) {
assetId
gas
digest
contract {
id
}
id
is
pc
ptr
Expand All @@ -88,9 +82,7 @@ query($id: TransactionId!) {
rd
reason
receiptType
to {
id
}
to
toAddress
val
len
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ query($owner: Address!, $after: String, $before: String, $first: Int, $last: Int
assetId
gas
digest
contract {
id
}
id
is
pc
ptr
Expand All @@ -42,9 +40,7 @@ query($owner: Address!, $after: String, $before: String, $first: Int, $last: Int
rd
reason
receiptType
to {
id
}
to
toAddress
val
len
Expand Down Expand Up @@ -79,9 +75,7 @@ query($owner: Address!, $after: String, $before: String, $first: Int, $last: Int
assetId
gas
digest
contract {
id
}
id
is
pc
ptr
Expand All @@ -91,9 +85,7 @@ query($owner: Address!, $after: String, $before: String, $first: Int, $last: Int
rd
reason
receiptType
to {
id
}
to
toAddress
val
len
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ query($after: String, $before: String, $first: Int, $last: Int) {
assetId
gas
digest
contract {
id
}
id
is
pc
ptr
Expand All @@ -42,9 +40,7 @@ query($after: String, $before: String, $first: Int, $last: Int) {
rd
reason
receiptType
to {
id
}
to
toAddress
val
len
Expand Down Expand Up @@ -79,9 +75,7 @@ query($after: String, $before: String, $first: Int, $last: Int) {
assetId
gas
digest
contract {
id
}
id
is
pc
ptr
Expand All @@ -91,9 +85,7 @@ query($after: String, $before: String, $first: Int, $last: Int) {
rd
reason
receiptType
to {
id
}
to
toAddress
val
len
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,13 @@ query($id: TransactionId!) {
id
txPointer
inputAssetIds
inputContracts {
id
}
inputContracts
inputContract {
utxoId
balanceRoot
stateRoot
txPointer
contract {
id
}
contractId
}
inputs {
__typename
Expand All @@ -39,9 +35,7 @@ query($id: TransactionId!) {
balanceRoot
stateRoot
txPointer
contract {
id
}
contractId
}
... on InputMessage {
sender
Expand Down Expand Up @@ -81,9 +75,7 @@ query($id: TransactionId!) {
assetId
}
... on ContractCreated {
contract {
id
}
contract
stateRoot
}
}
Expand Down Expand Up @@ -117,9 +109,7 @@ query($id: TransactionId!) {
assetId
gas
digest
contract {
id
}
id
is
pc
ptr
Expand All @@ -129,9 +119,7 @@ query($id: TransactionId!) {
rd
reason
receiptType
to {
id
}
to
toAddress
val
len
Expand Down Expand Up @@ -166,9 +154,7 @@ query($id: TransactionId!) {
assetId
gas
digest
contract {
id
}
id
is
pc
ptr
Expand All @@ -178,9 +164,7 @@ query($id: TransactionId!) {
rd
reason
receiptType
to {
id
}
to
toAddress
val
len
Expand Down
Loading

0 comments on commit a838222

Please sign in to comment.