Skip to content

feat: implement GraphQL interface to the middleware DB#2162

Draft
radrow wants to merge 62 commits intomasterfrom
radrow/graph-ql
Draft

feat: implement GraphQL interface to the middleware DB#2162
radrow wants to merge 62 commits intomasterfrom
radrow/graph-ql

Conversation

@radrow
Copy link
Copy Markdown
Member

@radrow radrow commented Sep 30, 2025

No description provided.

Comment on lines +3 to +11
# Ensure consistent node name for tests to match persisted DB owner (avoids :wrong_db_owner_node)
config :kernel, :distributed, [:'aeternity@localhost']

# Do not start embedded node services for GraphQL/data correctness tests to avoid DB owner mismatch
# Use full node services in tests; ensure you invoke tests with:
# elixir --name aeternity@localhost -S mix test
config :ae_mdw, :start_node_services, true
config :ae_mdw, :sync, true

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This should be removed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this file be restored from master? Is there a reason for this change?

docs/graphql.md Outdated
Comment on lines +122 to +149
---
## Security Considerations
- Depth & complexity limits are not yet enforced (add them before exposing publicly).
- Rate limiting is inherited from existing stack (none specific to GraphQL yet).
- User input is limited to IDs now; later additions must validate pagination cursors and filters.

---
## Contributing
Open a PR adding new fields and include:
- Schema changes
- Resolver(s)
- Unit tests (success + failure)
- Brief addition to this doc (Roadmap or new section)

---
## FAQ
**Why Absinthe instead of generating GraphQL from REST automatically?**
Absinthe offers strong flexibility, custom middleware, and Elixir-native patterns for batching and instrumentation.

**Will REST be deprecated?**
Not in the short term. GraphQL is additive and will target aggregate and selective data retrieval patterns first.

**How do I enable GraphiQL in prod for debugging?**
You should not. If absolutely necessary, guard it behind an env flag and temporary branch only.

---
## Support / Contact
File an issue in the repository with the `graphql` label for feature requests or bugs.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Remove

Comment on lines +4 to +28
import_types(AeMdwWeb.GraphQL.Schema.Helpers.CustomTypes)

import_types(AeMdwWeb.GraphQL.Schema.Types.AccountTypes)
import_types(AeMdwWeb.GraphQL.Schema.Types.BlockTypes)
import_types(AeMdwWeb.GraphQL.Schema.Types.ContractTypes)
import_types(AeMdwWeb.GraphQL.Schema.Types.NameTypes)
import_types(AeMdwWeb.GraphQL.Schema.Types.StatsTypes)
import_types(AeMdwWeb.GraphQL.Schema.Types.StatusTypes)
import_types(AeMdwWeb.GraphQL.Schema.Types.TransactionTypes)
import_types(AeMdwWeb.GraphQL.Schema.Types.ChannelTypes)
import_types(AeMdwWeb.GraphQL.Schema.Types.Aex9Types)
import_types(AeMdwWeb.GraphQL.Schema.Types.Aex141Types)
import_types(AeMdwWeb.GraphQL.Schema.Types.OracleTypes)

import_types(AeMdwWeb.GraphQL.Schema.Queries.AccountQueries)
import_types(AeMdwWeb.GraphQL.Schema.Queries.BlockQueries)
import_types(AeMdwWeb.GraphQL.Schema.Queries.ContractQueries)
import_types(AeMdwWeb.GraphQL.Schema.Queries.NameQueries)
import_types(AeMdwWeb.GraphQL.Schema.Queries.StatsQueries)
import_types(AeMdwWeb.GraphQL.Schema.Queries.StatusQueries)
import_types(AeMdwWeb.GraphQL.Schema.Queries.TransactionQueries)
import_types(AeMdwWeb.GraphQL.Schema.Queries.ChannelQueries)
import_types(AeMdwWeb.GraphQL.Schema.Queries.Aex9Queries)
import_types(AeMdwWeb.GraphQL.Schema.Queries.Aex141Queries)
import_types(AeMdwWeb.GraphQL.Schema.Queries.OracleQueries)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Maybe allow import_types to take a list as well?

import_types([
  AeMdwWeb.GraphQL.Schema.Types.AccountTypes,
  AeMdwWeb.GraphQL.Schema.Types.BlockTypes
])

Or maybe even multi-arg if possible

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have tried this, but it's not running. Maybe it's not possible to do so?

@ghallak
Copy link
Copy Markdown
Member

ghallak commented Nov 10, 2025

@radrow For docs auto generation, first run the mdw locally, and then run docker compose up from inside docs/graphql_doc_gen. The docs should be available at http://localhost:4400

@ghallak
Copy link
Copy Markdown
Member

ghallak commented Nov 10, 2025

@radrow I have noticed this endpoint /debug/dex/:contract_id/swaps but haven't added support for it in the graphql API. Do you know what is it for?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The entire file needs a rewrite.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@radrow do you know what is change is about?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@radrow the change here seems random. Is this an intended change?

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.

2 participants