Documentation Index Fetch the complete documentation index at: https://docs.prism.byescaleira.com/llms.txt
Use this file to discover all available pages before exploring further.
GraphQL Playground
Prism ships with a built-in GraphQL playground — an interactive browser UI where you can write queries, explore your schema, and test mutations in real time.
Quick Setup
Define your schema
Create your PrismGraphQLSchema with query and mutation types.
Add the middleware
Mount PrismGraphQLMiddleware on your server.
Add the playground
Mount PrismGraphQLPlayground for the interactive UI.
Open in browser
Navigate to http://localhost:8080/graphql/playground.
let server = PrismHTTPServer ( port : 8080 )
// Your schema
let schema = PrismGraphQLSchema ( query : queryType, mutation : mutationType)
// Mount GraphQL endpoint at /graphql
let graphqlMiddleware = PrismGraphQLMiddleware ( schema : schema, path : "/graphql" )
await server. use (graphqlMiddleware)
// Mount playground UI at /graphql/playground
let playground = PrismGraphQLPlayground (
path : "/graphql/playground" ,
graphqlEndpoint : "/graphql"
)
await server. use (playground)
try await server. start ()
Now visit http://localhost:8080/graphql/playground to start exploring.
How It Works
The playground provides:
Query editor with syntax highlighting
Variables panel for parameterized queries
Response viewer with formatted JSON
Keyboard shortcut — Cmd+Enter (or Ctrl+Enter) to execute
The playground is a self-contained HTML page embedded in the binary — no external CDN or network requests needed. It works completely offline.
Passing Context
Pass application context (like a database connection) to your resolvers via the middleware:
let db = try PrismDatabase ( path : "app.db" )
let graphqlMiddleware = PrismGraphQLMiddleware (
schema : schema,
path : "/graphql" ,
context : db // Available as info.context in resolvers
)
API Endpoints
The middleware handles both GET and POST requests:
curl -X POST http://localhost:8080/graphql \
-H "Content-Type: application/json" \
-d '{"query": "{ hello }", "variables": {}}'
curl "http://localhost:8080/graphql?query=%7B%20hello%20%7D"
Introspection
The playground uses introspection to discover your schema. Try this query to see all available types:
{
__schema {
queryType {
name
}
mutationType {
name
}
types {
name
fields {
name
type {
name
}
}
}
}
}
Production Considerations
The GraphQL playground should typically be disabled in production to prevent unauthorized schema exploration. Consider mounting it conditionally:
let config = PrismConfig. load ()
await server. use (graphqlMiddleware)
if config.isDevelopment {
await server. use ( PrismGraphQLPlayground ())
}
What’s Next
Schema Define more complex schemas with nested types
MCP Server Build AI tool servers with MCP