Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
**/ipfs-cache
**/data
*.json
.env
.env
**/.fastembed_cache
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ docker run \
### 2. Compile and run the indexer
In a separate terminal, run the following commands:
```bash
CFLAGS='-std=gnu17' cargo run --bin sink -- \
--reset-db \
CFLAGS='-std=gnu17' cargo run --release --bin sink -- \
--no-versioning \
--no-governance \
--neo4j-uri neo4j://localhost:7687 \
--neo4j-user neo4j \
--neo4j-pass neo4j
Expand All @@ -36,6 +37,11 @@ CFLAGS='-std=gnu17' cargo run --bin api -- \
--neo4j-user neo4j \
--neo4j-pass neo4j
```
Schema introspection

```
npx get-graphql-schema http://127.0.0.1:8080/graphql > api/schema.graphql
```

## GRC20 CLI
Coming soon™️
145 changes: 121 additions & 24 deletions api/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ type Entity {
"""Entity ID"""
id: String!

"""
The space ID of the entity (note: the same entity can exist in multiple spaces)
"""
spaceId: String!
createdAt: String!
createdAtBlock: String!
updatedAt: String!
updatedAtBlock: String!

"""Entity name (if available)"""
name: String

Expand All @@ -47,15 +56,6 @@ type Entity {
"""Types of the entity (which are entities themselves)"""
types: [Entity!]!

"""
The space ID of the entity (note: the same entity can exist in multiple spaces)
"""
spaceId: String!
createdAt: String!
createdAtBlock: String!
updatedAt: String!
updatedAtBlock: String!

"""Attributes of the entity"""
attributes(filter: AttributeFilter): [Triple!]!

Expand Down Expand Up @@ -143,6 +143,50 @@ enum OrderDirection {
DESC
}

type Property {
"""Entity ID"""
id: String!

"""
The space ID of the entity (note: the same entity can exist in multiple spaces)
"""
spaceId: String!
createdAt: String!
createdAtBlock: String!
updatedAt: String!
updatedAtBlock: String!

"""Entity name (if available)"""
name(strict: Boolean! = true): String

"""Entity description (if available)"""
description: String

"""Entity cover (if available)"""
cover: String

"""Entity blocks (if available)"""
blocks: [Entity!]!

"""Types of the entity (which are entities themselves)"""
types: [Entity!]!

"""Attributes of the entity"""
attributes(filter: AttributeFilter): [Triple!]!

"""Relations outgoing from the entity"""
relations(where: EntityRelationFilter): [Relation!]!

"""Versions of the entity, ordered chronologically"""
versions: [EntityVersion!]!

"""Value type of the property"""
valueType: Entity

"""Value type of the property"""
relationValueType: Entity
}

"""Relation object"""
type Relation {
"""Relation ID"""
Expand Down Expand Up @@ -187,10 +231,10 @@ input RelationFilter {

type RootQuery {
"""Returns a single space by ID"""
space(id: String!): Space
space(id: String!, version: String): Space

"""Returns multiple spaces according to the provided filter"""
spaces(where: SpaceFilter, first: Int, skip: Int): [Space!]!
spaces(where: SpaceFilter, version: String, first: Int! = 100, skip: Int! = 0): [Space!]!

"""Returns a single account by ID"""
account(id: String!): Account
Expand All @@ -199,23 +243,72 @@ type RootQuery {
accountByAddress(address: String!): Account

"""Returns multiple accounts according to the provided filter"""
accounts(where: AccountFilter, first: Int, skip: Int): [Account!]!
accounts(where: AccountFilter, first: Int! = 100, skip: Int! = 0): [Account!]!

"""Returns a single entity identified by its ID and space ID"""
entity(id: String!, spaceId: String!, versionId: String): Entity
entity(id: String!, spaceId: String!, versionId: String, strict: Boolean! = true): Entity

"""
Returns multiple entities according to the provided space ID and filter
"""
entities(spaceId: String!, orderBy: String, orderDirection: OrderDirection, where: EntityFilter, first: Int, skip: Int): [Entity!]!
entities(spaceId: String!, orderBy: String, orderDirection: OrderDirection, where: EntityFilter, first: Int! = 100, skip: Int! = 0, strict: Boolean! = true): [Entity!]!

"""Returns a single relation identified by its ID and space ID"""
relation(id: String!, spaceId: String!, versionId: String): Relation
relation(id: String!, spaceId: String!, versionId: String, strict: Boolean! = true): Relation

"""
Returns multiple relations according to the provided space ID and filter
"""
relations(spaceId: String!, orderBy: String, orderDirection: OrderDirection, where: RelationFilter, first: Int, skip: Int): [Relation!]!
relations(spaceId: String!, orderBy: String, orderDirection: OrderDirection, where: RelationFilter, first: Int! = 100, skip: Int! = 0, strict: Boolean! = true): [Relation!]!

"""
Returns a single triple identified by its entity ID, attribute ID, space ID and
optional version ID
"""
triple(entityId: String!, attributeId: String!, spaceId: String!, versionId: String, strict: Boolean! = true): Triple
search(query: String!, first: Int! = 100): [Triple!]!
}

"""SchemaType object"""
type SchemaType {
"""Entity ID"""
id: String!

"""
The space ID of the entity (note: the same entity can exist in multiple spaces)
"""
spaceId: String!
createdAt: String!
createdAtBlock: String!
updatedAt: String!
updatedAtBlock: String!

"""Entity name (if available)"""
name(strict: Boolean! = true): String

"""Entity description (if available)"""
description: String

"""Entity cover (if available)"""
cover: String

"""Entity blocks (if available)"""
blocks: [Entity!]!

"""Types of the entity (which are entities themselves)"""
types: [Entity!]!

"""Attributes of the entity"""
attributes(filter: AttributeFilter): [Triple!]!

"""Relations outgoing from the entity"""
relations(where: EntityRelationFilter): [Relation!]!

"""Versions of the entity, ordered chronologically"""
versions: [EntityVersion!]!

"""Properties of the Type"""
properties(first: Int! = 100, skip: Int! = 0): [Property!]!
}

type Space {
Expand Down Expand Up @@ -244,16 +337,19 @@ type Space {
personalSpaceAdminPlugin: String

"""Members of the space"""
members(first: Int, skip: Int): [Account!]!
members(first: Int! = 100, skip: Int! = 0): [Account!]!

"""Editors of the space"""
editors(first: Int, skip: Int): [Account!]!
editors(first: Int! = 100, skip: Int! = 0): [Account!]!

"""Parent spaces of this space"""
parentSpaces(first: Int, skip: Int): [Space!]!
parentSpaces(first: Int! = 100, skip: Int! = 0): [Space!]!

"""Subspaces of this space"""
subspaces(first: Int, skip: Int): [Space!]!
subspaces(first: Int! = 100, skip: Int! = 0): [Space!]!
types(first: Int! = 100, skip: Int! = 0, strict: Boolean! = true): [SchemaType!]!
type(id: String!, strict: Boolean! = true): SchemaType
entities(orderBy: String, orderDirection: OrderDirection, where: EntityFilter, first: Int! = 100, skip: Int! = 0, strict: Boolean! = true): [Entity!]!
}

input SpaceFilter {
Expand All @@ -265,10 +361,10 @@ input SpaceFilter {
networkNot: String
networkIn: [String!]
networkNotIn: [String!]
governanceType: String
governanceTypeNot: String
governanceTypeIn: [String!]
governanceTypeNotIn: [String!]
governanceType: SpaceGovernanceType
governanceTypeNot: SpaceGovernanceType
governanceTypeIn: [SpaceGovernanceType!]
governanceTypeNotIn: [SpaceGovernanceType!]
daoContractAddress: String
daoContractAddressNot: String
daoContractAddressIn: [String!]
Expand Down Expand Up @@ -314,6 +410,7 @@ type Triple {

"""Name of the attribute (if available)"""
name: String
entity: Entity
}

enum ValueType {
Expand Down
2 changes: 2 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ COPY --from=builder /kg-node/target/release/sink .
COPY --from=builder /kg-node/geo-substream.spkg .

CMD ./sink \
--no-versioning \
--no-governance \
--neo4j-uri $neo4j_uri \
--neo4j-user $neo4j_user \
--neo4j-pass $neo4j_pass
Expand Down
19 changes: 13 additions & 6 deletions sink/src/events/edit_published.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,19 @@ impl EventHandler {
return Ok(());
}

let version_index = mapping::new_version_index(block.block_number, index);
let edit_medatata =
models::Edit::new(edit.name, edit.content_uri, Some(version_index.clone()));
let proposal_id = Proposal::gen_id(&edit.space_plugin_address, &edit.proposal_id);
self.create_edit_relations(block, edit_medatata, &edit.space_id, &proposal_id)
.await?;
let version_index = if self.versioning {
mapping::new_version_index(block.block_number, index)
} else {
"0".to_string()
};

if self.governance {
let edit_medatata =
models::Edit::new(edit.name, edit.content_uri, Some(version_index.clone()));
let proposal_id = Proposal::gen_id(&edit.space_plugin_address, &edit.proposal_id);
self.create_edit_relations(block, edit_medatata, &edit.space_id, &proposal_id)
.await?;
}

// Group ops by type
let num_ops = edit.ops.len();
Expand Down
Loading