enum Episode { NEWHOPE, EMPIRE, JEDI } interface Character { id: String! name: String friends: [Character] appearsIn: [Episode] } type Human implements Character { id: String! name: String friends: [Character] appearsIn: [Episode] homePlanet: String } type Droid implements Character { id: String! name: String friends: [Character] appearsIn: [Episode] primaryFunction: String } type Query { hero(episode: Episode): Character human(id: String!): Human droid(id: String!): Droid } We begin by setting up our schema.
コード例 #1
0
 /**
  * Helper function to test a query and the expected response.
  */
 private function validationErrors($query)
 {
     $ast = Parser::parse($query);
     return DocumentValidator::validate(StarWarsSchema::build(), $ast);
 }
コード例 #2
0
 /**
  * Helper function to test a query and the expected response.
  */
 private function assertValidQuery($query, $expected)
 {
     $this->assertEquals(['data' => $expected], GraphQL::execute(StarWarsSchema::build(), $query));
 }
コード例 #3
0
 /**
  * Helper function to test a query with params and the expected response.
  */
 private function assertValidQueryWithParams($query, $params, $expected)
 {
     $this->assertEquals(['data' => $expected], GraphQL::execute(StarWarsSchema::build(), $query, null, null, $params));
 }