Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

GraphQL Basic Example

A simple example demonstrating the GraphQL extension for Forge.

Running

cd v2/examples/graphql-basic
go run main.go

Endpoints

Try It Out

Using cURL

# Hello query
curl -X POST http://localhost:8080/graphql \
  -H "Content-Type: application/json" \
  -d '{"query":"{ hello(name: \"World\") }"}'

# Version query
curl -X POST http://localhost:8080/graphql \
  -H "Content-Type: application/json" \
  -d '{"query":"{ version }"}'

# Echo mutation
curl -X POST http://localhost:8080/graphql \
  -H "Content-Type: application/json" \
  -d '{"query":"mutation { echo(message: \"Hello GraphQL\") }"}'

Using Playground

Visit http://localhost:8080/playground and try:

query {
  hello(name: "Forge")
  version
}

mutation {
  echo(message: "Testing mutations")
}

Features Demonstrated

  • ✅ Query operations
  • ✅ Mutation operations
  • ✅ GraphQL Playground
  • ✅ Automatic schema generation
  • ✅ Type-safe resolvers
  • ✅ Metrics and logging
  • ✅ Query caching