Open AdrianKBL opened 2 months ago
subscription {
nft(
where: {
spender: { _eq: 3654319 }
account_id: { _eq: 2665305 }
token_id: { _eq: 3515204 }
}
) {
token_id
serial_number
}
}
.In subscriptions:
- All data received
- Modify spender
.In subscriptions:
- All data received
- 🚀 ~ patches.forEach ~ patch: {"op":"remove","path":"/data/nft/103","value":{"token_id":3515204,"serial_number":170}}
subscription {
nft(where: { account_id: { _eq: 2665305 }, token_id: { _eq: 3515204 } }) {
token_id
serial_number
spender
}
}
.In subscriptions:
- All data received
- Modify spender
.In subscriptions:
- All data received
- patches.forEach ~ patch: {"op":"replace","path":"/data/nft/118/spender","value":null}
subscription {
nft(where: { account_id: { _eq: 2665305 }, token_id: { _eq: 3515204 } }) {
token_id
serial_number
}
}
.In subscriptions:
- All data received
- Modify spender
.In subscriptions:
- No patches received
subscription {
nft(
limit: 2
where: {
spender: { _eq: 3654319 }
account_id: { _eq: 2665305 }
token_id: { _eq: 3515204 }
}
) {
token_id
serial_number
spender
}
}
.In subscriptions:
- All data received
- Modify spender
.In subscriptions:
- No patches received
Inconsistencies in Handling Changes:
spender
), leading to different operations (remove
, replace
, or no changes).Inefficiency in Data Return:
Poor Usability of External Identifiers:
patches
include internal identifiers that are not meaningful or useful to users.To address these issues, it's crucial to:
patches
are meaningful to users to enhance system usability.@AdrianKBL @pat-rg
We are using the JSON patch specification. Here is the library and tools we are importing - https://github.com/hgraph-io/sdk/blob/90b2759b5aaaf7a05d3daa1601569279344ab2d6/src/client/index.ts#L4
The number is the position in the in the array: https://datatracker.ietf.org/doc/html/rfc6902#appendix-A.2
You may consider writing subscriptions ONLY for the critical data you want to be notified on change vs. placing the whole query in a subscription. See https://www.apollographql.com/docs/react/data/subscriptions/#when-to-use-subscriptions
@tmctl JSON Patch specification does not require returning the full resource after applying a patch. Would it be possible to return only the patch operations instead of the full resource to avoid memory issues? That could indeed be a useful approach, especially for larger resources (ex: all NFTs of a spender).
hi @pat-rg our API doesn't implement JSON Patch, so this code would need to be run on a server or on the client side.
we can expose a relay endpoint - https://relay.dev. Maybe some features of this might help your use cases?
Good morning,
I'm currently testing the new
patchedSubscriptions
to implement them in our DApps to improve performance, and I'm encountering a few issues:Balance updated at patch:
/data/entity_by_pk/token_account/39/token/total_supply
- New value:27282926759423626
. What does the39
aftertoken_account
refer to? How can I determine which token this new value belongs to? Given that we have numerous tokens, different balances, various public keys for each token, and different supplies for each token, I need each value to clearly identify a specific token. For instance, if a key changes, it should indicate what type of key it is.Is there a way to subscribe to a specific field? For example, there are too many different burns and mints on Hedera concerning FTs. I don't want to keep receiving notifications for each burn that occurs for each token ID, but I do want to get notifications when the balance changes.
Regarding NFTs, the value being returned includes the Token ID and Serial Number, which is great. However, for NFTs, the path should ideally be something like
/data/tokenId/serialNumber
instead of/data/nft/5
, as I don't know what the5
refers to.I didn't test other operations, but I guess we will have these problems in many different operations.
Example of a subscription:
Query
patchedSubscription