graphene_server 0.0.1+1
graphene_server: ^0.0.1+1 copied to clipboard
A GraphQL inspired server and JSON based Schema.
Graphene Server #
A GraphQL inspired server and JSON based Schema. Hecho en 🇵🇷 por Radamés J. Valentín Reyes
HTTP POST Request body #
In JSON format
Query #
{
"variables": {
"variable1": 2,
"variable2": "Hello World"
},
"query": "functionName",
"schema": {
"name": "",
"age": "",
"favoriteMovies": {
"name": "",
"realeaseYear": ""
}
}
}
Mutation #
{
"variables": {
"variable1": 2,
"variable2": "Hello World"
},
"mutation": "functionName",
"schema": {
"name": "",
"age": "",
"favoriteMovies": {
"name": "",
"realeaseYear": ""
}
}
}
Library use examples #
Dart Server #
import 'package:graphene_server/graphene_server.dart';
import 'dart:io';
void main()async{
String message = "Hello World";
await startServer(
server: await HttpServer.bind(InternetAddress.loopbackIPv4, 8080),
query: GrapheneQuery(
resolver: {
"helloWorld": (arguments)async{
return '{"message": "$message"}';
},
},
),
mutations: GrapheneMutation(
resolver: {
"helloWorld": (arguments)async{
message = arguments["newMessage"];
return '{"message": "$message"}';
},
},
),
);
}
Dart request example #
Schema support is not yet available. Just pass an empty map/object for now.
Request method is always of type POST.
Request body example below. Request body must always be of type JSON.
{
"variables": {
"newMessage": "New Message"
},
"mutation": "helloWorld",
"schema": {}
}
