Skip to content

Conversation

cmwhited
Copy link
Collaborator

@cmwhited cmwhited commented Jun 10, 2025

Description

The @graphprotocol/hypergraph-react package currently maintains a definition for Mapping which tells the HypergraphSpaceProvider how to retrieve entities for the given schema types from the Knowledge Graph.

After discussion, it was decided that typesync should be responsible for this logic as it is the framework for letting users build, maintain, and publish their schemas to the Knowledge Graph and part of this action is the generated Mapping.

This PR creates a new package: @graphprotocol/typesync that:

  • exposes this Mapping type definition
  • exposes a generateMapping function that takes in a schema object and from it:
    • iterates through the types and type properties and for each
      • checks if the type/property comes from an existing Knowledge Graph type/property
        • if not, creates the correct Op using the grc-20 lib
    • builds the Mapping entry from the existing/created Knowledge Graph Ids

Open questions

  • In order for the types/properties to be published to the Knowledge Graph, a wallet needs to perform the action. What wallet should this be?
    • when the connect app is ready, we will connect the typesync app to it. the authenticated user will publish the types/properties to the space created for their application
  • In what scenario would the typeIds have more than one entry based off this schema? Is it if: the type comes from the Knowledge Graph, but there are new properties being created/edited so the typeIds array would be: the initial type id from the Knowledge Graph + the newly generated id for the type with the property changes
  • What is the use of the relations property? Is this for props of dataType === RELATION and it would be the GRC-20 id of the relation type id?

Copy link

vercel bot commented Jun 10, 2025

@cmwhited is attempting to deploy a commit to the The Graph Foundation team on Vercel, but is not a member of this team. To resolve this issue, you can:

  • Make your repository public. Collaboration is free for open source and public repositories.
  • Add @cmwhited as a member. A Pro subscription is required to access Vercel's collaborative features.
    • If you're the owner of the team, click here and add @cmwhited as a member.
    • If you're the user who initiated this build request, click here to request access.
    • If you're already a member of the The Graph Foundation team, make sure that your Vercel account is connected to your GitHub account.

To read more about collaboration on Vercel, click here.

@cmwhited cmwhited requested review from baiirun and nikgraf June 10, 2025 18:35
Comment on lines 314 to 318
/**
* @todo fill in the relationValueTypes and properties for creating a relation property
*/
relationValueTypes: [],
properties: [],
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@baiirun could you help me understand the id(s) I would pass here for creating the relation property?

Copy link
Contributor

@baiirun baiirun Jul 10, 2025

Choose a reason for hiding this comment

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

Not entirely sure what properties is here. Might be a bug in grc-20. My guess is we copied the interface from createType.

For relationValueTypes it should be the id of whatever type we want to use as the target for a relation. For example,Relation(Person) requires that a relation points to a Person. The relation value type for this would be the Person entity id.

If you had a property called Employees that should point to a Person, it might look like this

Graph.createProperty({
    name: "Employees",
    dataType: "RELATION",
    relationValueTypes: ["<person-entity-id>"]
})

Copy link
Contributor

Choose a reason for hiding this comment

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

(We should probably rename relationValueTypes to something else since it's not obvious what it means)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The defineWorkspace function from vitest/config is deprecated in favor of config.test.projects

@cmwhited cmwhited changed the title [WIP] feat(mapping generation): create a typesync pkg to take a user-built schema and generate the mappings definition feat(mapping generation): create a typesync pkg to take a user-built schema and generate the mappings definition Jul 11, 2025
@cmwhited cmwhited marked this pull request as ready for review July 11, 2025 21:42
….whited/feat-typesync-pkg/mapping-generation
@cmwhited cmwhited merged commit 8a24c4b into main Jul 14, 2025
6 checks passed
@cmwhited cmwhited deleted the chris.whited/feat-typesync-pkg/mapping-generation branch July 14, 2025 18:22
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.

3 participants