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

feat(api): Add additional fields to EntityVersion GraphQL object #30

Open
cvauclair opened this issue Feb 21, 2025 · 0 comments
Open

feat(api): Add additional fields to EntityVersion GraphQL object #30

cvauclair opened this issue Feb 21, 2025 · 0 comments

Comments

@cvauclair
Copy link
Contributor

cvauclair commented Feb 21, 2025

Motivation

Add more contextual information to entity version objects to navigate historical data more effectively.

Implementation

Add the following fields to the EntityVersion GraphQL object:

type EntityVersion {
  # Version id
  id: String!

  # (NEW) Timestamp of when the edit was proposed (optional since doesn't apply to personal spaces and space imports)
  proposedAt: String,
  # (NEW) Block number of when the edit was proposed
  proposedAtBlock: String,
  # (NEW) Timestamp of when the edit was published/executed (null if still a proposal)
  publishedAt: String
  # (NEW) Block number of when the edit was proposed
  publishedAtBlock: String

  # (NEW) Author of the proposal for the edit
  author: String!

  # (NEW) List of attributes changed as part of the edit
  updatedAttributes: [Triple!]!

  # (NEW) Name of the entity at the time of the edit
  name: String
  # (NEW) Description of the entity at the time of the edit
  description: String
  # (NEW) Cover of the entity at the time of the edit
  cover: String
  # (NEW) Types of the entity at the time of the edit
  types: [Entity!]!
  # (NEW) Blocks of the entity at the time of the edit
  blocks: [Entity!]!

  # Entity attributes as of this version
  attributes(filter: AttributeFilter): [Triple!]!    
}

Alternatives

Since the EntityVersion object is getting quite complex (having both fields related to the version as well as all other entity fields), it might be worth refactoring the API and separating those.

Here would be an alternative design

type Query {
  # (NEW) Fetch all versions for an entity
  entityVersions(entityId: String): [EntityVersion!]!
}

type EntityVersion {
  # Version id
  id: String!

  # (NEW) Timestamp of when the edit was proposed (optional since doesn't apply to personal spaces and space imports)
  proposedAt: String,
  # (NEW) Block number of when the edit was proposed
  proposedAtBlock: String,
  # (NEW) Timestamp of when the edit was published/executed (null if still a proposal)
  publishedAt: String
  # (NEW) Block number of when the edit was proposed
  publishedAtBlock: String

  # (NEW) Author of the proposal for the edit
  author: String!

  # (NEW) List of attributes changed as part of the edit
  updatedAttributes: [Triple!]!

  # (NEW) Relation to the entity at the time of the edit
  entity: Entity!
}

type Entity {
  # (REMOVE)
  # versions: [EntityVersion!]!

  # (NEW) Version of the selected entity
  version: EntityVersion!
  ...
}

With this design, the query to get multiple versions of an entity would look like this:

query {
  entityVersions(entityId: "Foo", spaceId: "MySpace") {
    entity {
      name
    }
  }
}

Instead of

query {
  entity(entityId: "Foo", spaceId: "MySpace") {
    versions {
      name
    }
  }
}

Moreover, since versions are not really bound to entities, but rather to edits, it might make sense to change the naming of EntityVersion to EntityEdit, Edit or something along those lines.

@cvauclair cvauclair changed the title Add version filter to GraphQL API feat(api): Add additional fields to EntityVersion GraphQL object Feb 21, 2025
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

No branches or pull requests

1 participant