Application types
GraphQL applications
Describe object shapes with @Schema and expose query or mutation fields with @GraphQL sections. The native server accepts GraphQL operations at /graphql.
#!RUNE
@App
name = Greeting GraphQL
type = GraphQL
port = 3000
@Schema/Greeting
message = string
@GraphQL/Query/Greeting
greeting:
result = { message: "Hello from Rune" }
return result
@GraphQL/Mutation/Greeting
greet(message: string):
result = { message: message }
return result
Reading the syntax
- @App type = GraphQL starts the GraphQL server. @Schema/Greeting declares the fields of the Greeting object.
- @GraphQL/Query/Greeting declares query resolvers returning Greeting. Each resolver name ends with : and its indented steps return data.
- @GraphQL/Mutation/Greeting declares mutations. Arguments use name: type inside parentheses and become variables available to the resolver.
Run locally
Save this source as graphql.rune. Open http://127.0.0.1:3000/ for the native GraphQL playground, or POST operations to /graphql.
vectrune graphql.runeThe source uses the native @Schema and @GraphQL forms. The browser sandbox also understands @Type, @Query, and @Mutation shorthand; use the forms above for native servers.
Query and mutation syntax
raw ../../content/applications/operations.graphqlInteractive
Read, edit, run
Apply the code to prepare this browser example, then send a request. Document and AST inspection are available under the advanced controls.
i18n.Sandbox.code
Inspect document or AST
Changes not applied. Press Apply code to update the running example.
Output
View GraphQL schema
This playground simulates requests in your browser. Apply the code, then choose an endpoint and press Send Request.