Skip to content

Commit 6d2e2ed

Browse files
committed
add helloworld example
1 parent 034745c commit 6d2e2ed

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

examples/helloworld/index.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
// include the php-graphql-autoloader
3+
require '../../src/autoloader.php';
4+
5+
use GraphQL\Types\GraphQLObjectType;
6+
use GraphQL\Fields\GraphQLTypeField;
7+
use GraphQL\Types\GraphQLString;
8+
use GraphQL\Schemas\Schema;
9+
use GraphQL\Servers\Server;
10+
11+
// build the query type
12+
$QueryType = new GraphQLObjectType("Query", "Root Query", function (){
13+
return [
14+
new GraphQLTypeField(
15+
"hello",
16+
new GraphQLString(),
17+
"Your first hello world GraphQL-Application",
18+
function (){ return 'Hello world!'; }
19+
)
20+
];
21+
});
22+
23+
// build the schema
24+
$schema = new Schema($QueryType);
25+
26+
// start a server
27+
$server = new Server($schema);
28+
$server->listen();

0 commit comments

Comments
 (0)