GraphQL
Add a graphql endpoint inside any server block. NAIDE auto-generates the GraphQL schema from your schema declarations.
Basic Setup
server app port 3000:
graphql "/graphql"
This creates a GraphQL endpoint at /graphql with a default "hello" query.
Auto-Schema Generation
Define schemas in your server, and NAIDE generates matching GraphQL types and queries automatically:
server app port 3000:
schema User:
id auto
name str
email str
schema Post:
id auto
title str
body str
graphql "/graphql"
This generates:
type User { id: ID, name: String, email: String }type Post { id: ID, title: String, body: String }Query.users: [User],Query.user(id: ID): UserQuery.posts: [Post],Query.post(id: ID): Post
Type Mapping
| NAIDE Type | GraphQL Type |
|---|---|
| str | String |
| int | Int |
| num | Float |
| bool | Boolean |
| auto | ID |
Multi-Target
| Target | Library |
|---|---|
| Node.js | graphql + graphql-http |
| Bun | graphql (inline handler) |
| Python | graphene + flask-graphql |