コード例 #1
0
 public function testMutatesTheDataSet()
 {
     $mutation = 'mutation AddBWingQuery($input: IntroduceShipInput!) {
         introduceShip(input: $input) {
           ship {
             id
             name
           }
           faction {
             name
           }
           clientMutationId
         }
       }';
     $params = array('input' => array('shipName' => 'B-Wing', 'factionId' => '1', 'clientMutationId' => 'abcde'));
     $expected = array('introduceShip' => array('ship' => array('id' => 'U2hpcDo5', 'name' => 'B-Wing'), 'faction' => array('name' => 'Alliance to Restore the Republic'), 'clientMutationId' => 'abcde'));
     $result = GraphQL::execute(StarWarsSchema::getSchema(), $mutation, null, null, $params);
     $this->assertEquals(['data' => $expected], $result);
 }
コード例 #2
0
 /**
  * Helper function to test a query and the expected response.
  */
 private function assertValidQuery($query, $expected)
 {
     $result = GraphQL::execute(StarWarsSchema::getSchema(), $query);
     $this->assertEquals(['data' => $expected], $result);
 }