https://github.com/dsaouda/phpconf2017-graphql
Exemplo simples de graphql
https://github.com/dsaouda/phpconf2017-graphql
graphql php phpconf
Last synced: about 2 months ago
JSON representation
Exemplo simples de graphql
- Host: GitHub
- URL: https://github.com/dsaouda/phpconf2017-graphql
- Owner: dsaouda
- Created: 2017-12-07T10:25:30.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-11T22:02:11.000Z (over 8 years ago)
- Last Synced: 2025-03-22T04:41:29.619Z (about 1 year ago)
- Topics: graphql, php, phpconf
- Language: PHP
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# graphql phpconf 2017
Exemplos simples usados para fazer uma pequena demonostração de graphql no phpconf 2017
# rodando
execute em seu terminal `php -S 0.0.0.0:8080`
em um editor (você pode usar o [graphiql](https://github.com/graphql/graphiql)) informe a url `http:///02-cep.php`
# exemplos de querys
Separei algumas querys que podem ser usadas
## query
```
{
endereco(cep: "07083150") {
logradouro
localidade
bairro
uf
cep
}
}
```
## variable
```
query ($cep: String!){
endereco(cep: $cep) {
logradouro
localidade
bairro
uf
cep
}
}
#query variables
{
"cep": "07181100"
}
```
## alias
```
{
e1: endereco(cep: "07083150") {
logradouro
localidade
bairro
uf
cep
}
e2: endereco(cep: "07181100") {
localidade
}
e3: endereco(cep: "06020190") {
logradouro
uf
}
}
```
## fragments
```
{
e1: endereco(cep: "07083150") {
...detalhe
}
e2: endereco(cep: "07181100") {
...detalhe
}
e3: endereco(cep: "06020190") {
...detalhe
}
}
fragment detalhe on Endereco {
logradouro
localidade
uf
}
```
## directives
```
query ($cep: String!, $includeBairro: Boolean = true){
endereco(cep: $cep) {
logradouro
localidade
bairro @include(if: $includeBairro)
uf
cep
}
}
#query variables
{
"cep": "07181100",
"includeBairro": true
}
```
## mutation
```
mutation {
removerCache(cep: "06020190")
}
```