diff --git a/benchmarks/HugeSchemaBench.php b/benchmarks/HugeSchemaBench.php index 19d6837..7401ed2 100644 --- a/benchmarks/HugeSchemaBench.php +++ b/benchmarks/HugeSchemaBench.php @@ -1,10 +1,11 @@ 600, 'fieldsPerType' => 8, 'listFieldsPerType' => 2, - 'nestingLevel' => 10 + 'nestingLevel' => 10, ]); $this->schema = $this->schemaBuilder->buildSchema(); - $queryBuilder = new QueryGenerator($this->schema, 0.05); + $queryBuilder = new QueryGenerator($this->schema, 0.05); $this->smallQuery = $queryBuilder->buildQuery(); } @@ -46,8 +43,7 @@ class HugeSchemaBench { $this->schemaBuilder ->buildSchema() - ->getTypeMap() - ; + ->getTypeMap(); } public function benchSchemaLazy() @@ -69,9 +65,9 @@ class HugeSchemaBench private function createLazySchema() { return new Schema( - \GraphQL\Type\SchemaConfig::create() + SchemaConfig::create() ->setQuery($this->schemaBuilder->buildQueryType()) - ->setTypeLoader(function($name) { + ->setTypeLoader(function ($name) { return $this->schemaBuilder->loadType($name); }) ); diff --git a/benchmarks/StarWarsBench.php b/benchmarks/StarWarsBench.php index faa0a97..2fb2afb 100644 --- a/benchmarks/StarWarsBench.php +++ b/benchmarks/StarWarsBench.php @@ -1,5 +1,6 @@ getTypeMap() as $type) { - if ($type instanceof ObjectType) { - $totalFields += count($type->getFields()); + if (! ($type instanceof ObjectType)) { + continue; } + + $totalFields += count($type->getFields()); } - $this->maxLeafFields = max(1, round($totalFields * $percentOfLeafFields)); + $this->maxLeafFields = max(1, round($totalFields * $percentOfLeafFields)); $this->currentLeafFields = 0; } @@ -44,13 +49,12 @@ class QueryGenerator $qtype = $this->schema->getQueryType(); $ast = new DocumentNode([ - 'definitions' => [ - new OperationDefinitionNode([ - 'name' => new NameNode(['value' => 'TestQuery']), - 'operation' => 'query', - 'selectionSet' => $this->buildSelectionSet($qtype->getFields()) - ]) - ] + 'definitions' => [new OperationDefinitionNode([ + 'name' => new NameNode(['value' => 'TestQuery']), + 'operation' => 'query', + 'selectionSet' => $this->buildSelectionSet($qtype->getFields()), + ]), + ], ]); return Printer::doPrint($ast); @@ -58,12 +62,13 @@ class QueryGenerator /** * @param FieldDefinition[] $fields + * * @return SelectionSetNode */ public function buildSelectionSet($fields) { $selections[] = new FieldNode([ - 'name' => new NameNode(['value' => '__typename']) + 'name' => new NameNode(['value' => '__typename']), ]); $this->currentLeafFields++; @@ -87,12 +92,12 @@ class QueryGenerator $selections[] = new FieldNode([ 'name' => new NameNode(['value' => $field->name]), - 'selectionSet' => $selectionSet + 'selectionSet' => $selectionSet, ]); } $selectionSet = new SelectionSetNode([ - 'selections' => $selections + 'selections' => $selections, ]); return $selectionSet;