Unified GraphQL examples written in Go, Node.js, PHP.
- Unified GraphQL example template.
- Multiple languages: Go, Node.js, PHP.
- Easy to learn primary GraphQL.
- Test compatibility.
- HTTP services.
go get github.com/WindomZ/graphql-examples/...
npm install
# or
yarn
composer install
Each under the go
, nodejs
, php
directory paths.
If you have Go(go get)
, PHP(composer)
, Node.js(npm/yarn)
installed.
You can run and select service:
./run.sh
Run the test with all above languages:
./test.sh
Define a schema that is the basis for all queries:
// add a User type
type User {
id: String!
name: String
}
// define a schema
type Query {
hello(message: String): String
bye: String
user(id: String!): User
}
type Mutation {
sum(x: Int, y: Int): Int
}
The example queries on the above schema would be:
Query hello
:
query Query {
hello(message: "world")
}
Query bye
:
// test root values
query Query {
bye
}
Query user
:
// test numbers and some symbols
query Query {
user(id:"1") {
name
}
}
// test English
query Query {
user(id:"id") {
name
}
}
// test Chinese
query Query {
user(id:"编号") {
name
}
}
Query sum
:
mutation Calc {
sum(x: 1, y: 2)
}
- graphql Official documents
- graphql-js + express-graphql
- graphql-go
- graphql-php
Welcome to pull requests, report bugs, suggest ideas and discuss graphql-examples on issues page.
If you like it then you can put a ⭐ on it.
- Support Golang.
- Support Node.js.
- Support PHP.
- Support Java.
- Hello & Bye example template.
- Calc(sum) example template.
- User example template.
- Star Wars example template.
- HTTP services.
- HTTPS services.
- RPC services.