Created
April 22, 2020 00:54
-
-
Save marcosborges/27aea6bf0ebf290f5d82baf9a92e352c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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