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

WIP: Polymorphic Config + Resolution #80

Merged
merged 20 commits into from
Jan 28, 2025
Merged

Conversation

shrugs
Copy link
Contributor

@shrugs shrugs commented Jan 26, 2025

closes #64 and #65

  • full events schema (full disclosure: generated by claude but reviewed by me)
  • using user-provided polymorphic relationships (aka graphql's interfaces) within the graphql schema, as well as a config relating which graphql fields should be polymorphic
  • sets the stage for polymorphic plural queries needed to support namestone indexing
  • modifies executePluralQuery to support subquery selection

todo

  • switch to passing table references instead of tsNames
  • switch to more exact subgraph pascalcase implementation
  • polymorphic filter,orderby generation
  • remove middleware maskedErrors override (this was necessary to get stacktraces in development)
  • is there a better way to implement this? it's clean but not exactly 🤌
  • implement all of the relevant events in code
  • test with a diff at 4_000_000
  • remove endblock 4_000_000 hardcode
  • issue with typecheck in ensnode subproject using its more strict tsconfig against the code in ponder-subgraph-api.

@shrugs shrugs marked this pull request as ready for review January 27, 2025 22:45
@shrugs shrugs requested a review from a team as a code owner January 27, 2025 22:45
},
},
}),
);
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Comment on lines +238 to +244
// NOTE: this actually produces a bug in the subgraph's graphql layer — `resolver` is not nullable
// but there is never a resolver record created for the zeroAddress. so if you query the
// `resolver { id }` of a NewResolver event that set the resolver to zeroAddress
// ex: newResolver(id: "3745840-2") { id resolver {id} }
// you will receive a GraphQL type error. for subgraph compatibility we re-implement this
// behavior here, but it should be entirely avoided in a v2 restructuring of the schema.
resolverId: resolverAddress === zeroAddress ? zeroAddress : resolverId,
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

// simplifies generating the shared event column values from the ponder Event object
export function sharedEventValues(event: Omit<Event, "args">) {
return {
id: makeEventId(event.block.number, event.log.logIndex),
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice one

Copy link
Member

@lightwalker-eth lightwalker-eth left a comment

Choose a reason for hiding this comment

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

@shrugs Amazing work here 🚀 Looks good 👍

Copy link
Member

Choose a reason for hiding this comment

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

@shrugs Hahah, this is nuts 😅 Amazing work 💪

const id = makeResolverId(event.log.address, node);
const resolver = await upsertResolver(context, {

// upsert resolveer
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// upsert resolveer
// upsert resolver

@shrugs shrugs merged commit 2a7d24b into main Jan 28, 2025
2 checks passed
@shrugs shrugs deleted the feat/polymorphic-resolvers branch January 28, 2025 17:32
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.

Polymorphic Event GraphQL Resolver
3 participants