Skip to content

Commit

Permalink
Format docs
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia committed Dec 19, 2024
1 parent 5f1eda3 commit 52854f3
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 18 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ it: fix stan test docs ## Run the commonly used targets

.PHONY: help
help: ## Displays this list of targets with descriptions
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(firstword $(MAKEFILE_LIST)) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'
@grep --extended-regexp '^[a-zA-Z0-9_-]+:.*?## .*$$' $(firstword $(MAKEFILE_LIST)) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: setup
setup: vendor phpstan.neon ## Set up the project

.PHONY: fix
fix: rector php-cs-fixer ## Automatic code fixes
fix: rector php-cs-fixer prettier ## Automatic code fixes

.PHONY: rector
rector: vendor ## Automatic code fixes with Rector
Expand All @@ -19,6 +19,10 @@ rector: vendor ## Automatic code fixes with Rector
php-cs-fixer: vendor ## Fix code style
composer php-cs-fixer

.PHONY: prettier
prettier: ## Format code with prettier
prettier --write --tab-width=2 *.md **/*.md

phpstan.neon:
printf "includes:\n - phpstan.neon.dist" > phpstan.neon

Expand Down
128 changes: 112 additions & 16 deletions docs/class-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -430,37 +430,35 @@ public $variableValues;

```php
/**
* Helper method that returns names of all fields selected in query for
* $this->fieldName up to $depth levels.
* Returns names of all fields selected in query for `$this->fieldName` up to `$depth` levels.
*
* Example:
* query MyQuery{
* {
* root {
* id,
* id
* nested {
* nested1
* nested2 {
* nested3
* }
* nested1
* nested2 {
* nested3
* }
* }
* }
* }
*
* Given this ResolveInfo instance is a part of "root" field resolution, and $depth === 1,
* method will return:
* Given this ResolveInfo instance is a part of root field resolution, and $depth === 1,
* this method will return:
* [
* 'id' => true,
* 'nested' => [
* nested1 => true,
* nested2 => true
* ]
* 'nested1' => true,
* 'nested2' => true,
* ],
* ]
*
* Warning: this method it is a naive implementation which does not take into account
* conditional typed fragments. So use it with care for fields of interface and union types.
* This method does not consider conditional typed fragments.
* Use it with care for fields of interface and union types.
*
* @param int $depth How many levels to include in output
* @param int $depth How many levels to include in the output beyond the first
*
* @return array<string, mixed>
*
Expand All @@ -469,6 +467,104 @@ public $variableValues;
function getFieldSelection(int $depth = 0): array
```

```php
/**
* Returns names and args of all fields selected in query for `$this->fieldName` up to `$depth` levels, including aliases.
*
* The result maps original field names to a map of selections for that field, including aliases.
* For each of those selections, you can find the following keys:
* - "args" contains the passed arguments for this field/alias
* - "selectionSet" contains potential nested fields of this field/alias. The structure is recursive from here.
*
* Example:
* {
* root {
* id
* nested {
* nested1(myArg: 1)
* nested1Bis: nested1
* }
* alias1: nested {
* nested1(myArg: 2, mySecondAg: "test")
* }
* }
* }
*
* Given this ResolveInfo instance is a part of "root" field resolution, and $depth === 1,
* this method will return:
* [
* 'id' => [
* 'id' => [
* 'args' => [],
* ],
* ],
* 'nested' => [
* 'nested' => [
* 'args' => [],
* 'selectionSet' => [
* 'nested1' => [
* 'nested1' => [
* 'args' => [
* 'myArg' => 1,
* ],
* ],
* 'nested1Bis' => [
* 'args' => [],
* ],
* ],
* ],
* ],
* 'alias1' => [
* 'args' => [],
* 'selectionSet' => [
* 'nested1' => [
* 'nested1' => [
* 'args' => [
* 'myArg' => 2,
* 'mySecondAg' => "test,
* ],
* ],
* ],
* ],
* ],
* ],
* ]
*
* This method does not consider conditional typed fragments.
* Use it with care for fields of interface and union types.
* You can still alias the union type fields with the same name in order to extract their corresponding args.
*
* Example:
* {
* root {
* id
* unionPerson {
* ...on Child {
* name
* birthdate(format: "d/m/Y")
* }
* ...on Adult {
* adultName: name
* adultBirthDate: birthdate(format: "Y-m-d")
* job
* }
* }
* }
* }
*
* @param int $depth How many levels to include in the output beyond the first
*
* @throws \Exception
* @throws Error
* @throws InvariantViolation
*
* @return array<string, mixed>
*
* @api
*/
function getFieldSelectionWithAliases(int $depth = 0): array
```

## GraphQL\Language\DirectiveLocation

Enumeration of available directive locations.
Expand Down

0 comments on commit 52854f3

Please sign in to comment.