/**
  * Helper function to test a query and the expected response.
  *
  * @param $query
  * @param $expected
  */
 protected function assertQuery($query, $expected)
 {
     $this->assertEquals(['data' => $expected], GraphQL::execute($this->getStarWarsSchema(), $query));
 }
예제 #2
0
 public function testExposesDescriptionsOnEnums()
 {
     $schema = new Schema(new ObjectType('QueryRoot'));
     $request = '
         {
             typeKindType: __type(name: "__TypeKind") {
                 name,
                 description,
                 enumValues {
                     name,
                     description
                 }
             }
         }
     ';
     $expected = ['data' => ['typeKindType' => ['name' => '__TypeKind', 'description' => 'An enum describing what kind of type a given __Type is.', 'enumValues' => [['description' => 'Indicates this type is a scalar.', 'name' => 'SCALAR'], ['description' => 'Indicates this type is an object. `fields` and `interfaces` are valid fields.', 'name' => 'OBJECT'], ['description' => 'Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.', 'name' => 'INTERFACE'], ['description' => 'Indicates this type is a union. `possibleTypes` is a valid field.', 'name' => 'UNION'], ['description' => 'Indicates this type is an enum. `enumValues` is a valid field.', 'name' => 'ENUM'], ['description' => 'Indicates this type is an input object. `inputFields` is a valid field.', 'name' => 'INPUT_OBJECT'], ['description' => 'Indicates this type is a list. `ofType` is a valid field.', 'name' => 'LIST'], ['description' => 'Indicates this type is a non-null. `ofType` is a valid field.', 'name' => 'NON_NULL']]]]];
     $result = GraphQL::execute($schema, $request);
     $this->assertEquals($expected, $result);
 }
예제 #3
0
 /**
  * Helper function to test a query with params and the expected response.
  *
  * @param $query
  * @param $params
  * @param $expected
  */
 protected function assertQueryWithParams($query, $params, $expected)
 {
     $result = GraphQL::execute($this->getStarWarsSchema(), $query, NULL, $params);
     $this->assertEquals(['data' => $expected], $result);
 }