diff --git a/tests/GraphQLTest.php b/tests/GraphQLTest.php new file mode 100644 index 0000000..9617e9e --- /dev/null +++ b/tests/GraphQLTest.php @@ -0,0 +1,47 @@ + new ObjectType( + [ + 'name' => 'Query', + 'fields' => [ + 'sayHi' => [ + 'type' => Type::nonNull(Type::string()), + 'args' => [ + 'name' => [ + 'type' => Type::nonNull(Type::string()), + ], + ], + 'resolve' => static function ($value, $args) use ($promiseAdapter) { + return $promiseAdapter->createFulfilled(sprintf('Hi %s!', $args['name'])); + }, + ], + ], + ] + ), + ] + ); + + $promise = GraphQL::promiseToExecute($promiseAdapter, $schema, '{ sayHi(name: "John") }'); + $result = $promiseAdapter->wait($promise); + $this->assertSame(['data' => ['sayHi' => 'Hi John!']], $result->toArray()); + } +}