Skip to content

Instantly share code, notes, and snippets.

@marcosborges
Created April 22, 2020 00:54
Show Gist options
  • Save marcosborges/27aea6bf0ebf290f5d82baf9a92e352c to your computer and use it in GitHub Desktop.
Save marcosborges/27aea6bf0ebf290f5d82baf9a92e352c to your computer and use it in GitHub Desktop.
<?php declare(strict_types=1);
require_once 'vendor/autoload.php';
use Siler\Swoole;
use Siler\GraphQL;
use Siler\Http\Response;
// Enable CORS for GraphiQL
Response\header('Access-Control-Allow-Origin', '*');
Response\header('Access-Control-Allow-Headers', 'content-type');
$typeDefs = file_get_contents('path/to/schema.graphql');
$resolvers = [
'Query' => [
'message' => 'foo',
],
'Mutation' => [
'sum' => function ($root, $args) {
return $args['a'] + $args['b'];
},
],
];
#ESSA PARTE AQUI NAO SEI COMO ENCAIXAR
GraphQL\init(GraphQL\schema($typeDefs, $resolvers));
$server = fn() => Swoole\emit('Hello World');
Swoole\http($server)->start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment