Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add artifactUri, thumbnailUri, and displayUri to top level of Objkt #32

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

iworkinprogress
Copy link

This PR attempts to update Objkt to supply artifactUri, thumbnailUri, and displayUri outside of the metadata field. These are very common fields and nesting them only within metadata is problematic because it requires loading the entire metadata field to access them. Metadata can be huge for some Objkts because it contains the description of the project and a lot of other data that is not necessarily always needed.

I wasn't able to fully test this because I had issues getting the Docker container up and running:
#31
#27

@ciphrd ciphrd changed the base branch from main to dev September 24, 2022 08:30
})
thumbnailUri(@Root() objkt: Objkt, @Ctx() ctx: RequestContext) {
if (objkt.thumbnailUri) return objkt.thumbnailUri;
return ctx.genTokLoader.load(objkt.metadata?.thumbnailUri);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The genTokLoader is a DataLoader designed to batch queries to get a Generative Token from the database. Its load function accepts a Generative Token ID.

Ultimately, requesting the DataLoader in here is not required, as the data is already available in objkt.metadata.thumbnailUri already stored in memory at this point of execution.

})
displayUri(@Root() objkt: Objkt, @Ctx() ctx: RequestContext) {
if (objkt.displayUri) return objkt.displayUri;
return ctx.genTokLoader.load(objkt.metadata?.displayUri);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark as thumbnailUri

@FieldResolver((returns) => String, {
description: "IPFS uri pointing to the web page hosting the Generator code.",
})
artifactUri(@Root() objkt: Objkt, @Ctx() ctx: RequestContext) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This resolver should be removed as it can be derived from the Generative Token generativeUri and the objkt generationHash

https://gateway.fxhash.xyz/ipfs/${cid(generativeUri)}/?fxhash=${generationHash}

- Remove artificatUri
- Remove Data Loader wrapper for displayUri and thumbnailUri
@iworkinprogress
Copy link
Author

Addressed PR feedback with latest commit. Thanks for your help here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants