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/graphql api #7

Merged
merged 25 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
04e083c
feat: Initial prototype for GraphQL server
cvauclair Dec 11, 2024
63d48bb
feat: Add GraphQL API prototype
cvauclair Dec 12, 2024
4ef890e
refactor: Rename `node` to `indexer`
cvauclair Dec 12, 2024
ab795d1
devops: Add `api` to docker compose
cvauclair Dec 12, 2024
e5bfbbe
misc: Remove old files
cvauclair Dec 12, 2024
f51c740
refactor: Rename crates to match reference implementation
cvauclair Dec 12, 2024
35ea24c
misc: Cleanup old code
cvauclair Dec 12, 2024
669495e
feat: Add space id filter
cvauclair Dec 12, 2024
99f2a7b
misc: Rename `node` to `entity` in gql aoi
cvauclair Dec 12, 2024
3a01b0f
style: clippy+fmt
cvauclair Dec 12, 2024
7a2ee9b
feat: Update to latest substreams
cvauclair Dec 17, 2024
8be26c2
refactor: grc20 - neo4j mapping
cvauclair Dec 19, 2024
88790fd
refactor: More refactoring + add tests
cvauclair Dec 19, 2024
3ae7ecf
feat: Add triples, types and filters to GraphQL API
cvauclair Dec 20, 2024
e6b50a3
doc: Add docs to graphql schema
cvauclair Dec 20, 2024
08797ab
style: clippy + fmt
cvauclair Dec 20, 2024
c505109
devops: Update dockerfile
cvauclair Dec 20, 2024
d9a129b
devops: chagne api service port
cvauclair Dec 20, 2024
590766b
fix: docker compose
cvauclair Dec 20, 2024
dfe315b
devops: fix docker compose (again)
cvauclair Dec 20, 2024
0a32550
fix(api): Fix entities types filter
cvauclair Jan 8, 2025
baaa185
misc: Temporarily remove codegen crate from workspace
cvauclair Jan 8, 2025
abd1207
misc: Add back codegen to workspace
cvauclair Jan 8, 2025
e41929c
style: clippy + fmt
cvauclair Jan 8, 2025
0df7205
test(sdk): Fix attribute serialization tests
cvauclair Jan 8, 2025
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
666 changes: 576 additions & 90 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
resolver = "2"
members = [
"cli", "codegen", "core", "ipfs", "node", "sink", "web3-utils",
members = [ "api",
"cli", "codegen", "sdk", "ipfs", "sink", "substreams-utils", "web3-utils",
]

12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,21 @@ docker run \
```

### 2. Compile and run the indexer
In a separate terminal, run the following command:
In a separate terminal, run the following commands:
```bash
cargo run --bin kg-node -- \
--rollup \
cargo run --bin sink -- \
--reset-db \
--neo4j-uri neo4j://localhost:7687 \
--neo4j-user neo4j \
--neo4j-pass neo4j
```

```bash
cargo run --bin api -- \
--neo4j-uri neo4j://localhost:7687 \
--neo4j-user neo4j \
--neo4j-pass neo4j
```

## GRC20 CLI
Coming soon™️
25 changes: 25 additions & 0 deletions api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "api"
version = "0.1.0"
edition = "2021"

[dependencies]
anyhow = "1.0.94"
axum = "0.7.9"
clap = { version = "4.5.23", features = ["derive"] }
futures = "0.3.31"
juniper = "0.16.1"
juniper_axum = "0.1.1"
juniper_graphql_ws = "0.4.0"
serde = "1.0.216"
serde_json = "1.0.133"
tokio = { version = "1.42.0", features = ["macros", "rt-multi-thread"] }
tracing = "0.1.41"
tracing-subscriber = "0.3.19"

sdk = { version = "0.1.0", path = "../sdk" }
sink = { version = "0.1.0", path = "../sink" }
chrono = "0.4.39"

[dev-dependencies]
serde_path_to_error = "0.1.16"
133 changes: 133 additions & 0 deletions api/schema.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
input AttributeFilter {
valueType: ValueType
}

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

"""Entity name (if available)"""
name: 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!

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

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

"""Relations outgoing from the entity"""
relations: [Relation!]!
}

input EntityAttributeFilter {
attribute: String!
value: String
valueType: ValueType
}

input EntityWhereFilter {
spaceId: String
typesContain: [String!]
attributesContain: [EntityAttributeFilter!]
}

type Options {
format: String
unit: String
language: String
}

type Query {
"""Returns a single entity identified by its ID and space ID"""
entity(id: String!, spaceId: String!): Entity

"""
Returns multiple entities according to the provided space ID and filter
"""
entities(where: EntityWhereFilter): [Entity!]!

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

"""
Returns multiple relations according to the provided space ID and filter
"""
relations(spaceId: String!, filter: RelationFilter): [Relation!]!
}

"""
Relation object

Note: Relations are also entities, but they have a different structure in the database.
In other words, the Relation object is a "view" on a relation entity. All relations
can also be queried as entities.
"""
type Relation {
"""Relation ID"""
id: String!

"""Relation name (if available)"""
name: String
createdAt: String!
createdAtBlock: String!
updatedAt: String!
updatedAtBlock: String!

"""Attributes of the relation"""
attributes: [Triple!]!

"""Relation types of the relation"""
relationTypes: [Entity!]!

"""Entity from which the relation originates"""
from: Entity!

"""Entity to which the relation points"""
to: Entity!

"""Relations outgoing from the relation"""
relations: [Relation!]!
}

"""Relation filter input object"""
input RelationFilter {
"""Filter by relation types"""
relationTypes: [String!]
}

type Triple {
"""Attribute ID of the triple"""
attribute: String!

"""Value of the triple"""
value: String!

"""Value type of the triple"""
valueType: ValueType!

"""Options of the triple (if any)"""
options: Options!

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

enum ValueType {
TEXT
NUMBER
CHECKBOX
URL
TIME
POINT
}

1 change: 1 addition & 0 deletions api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod query_mapping;
Loading
Loading