Skip to content

Commit 1ec7adb

Browse files
authored
Restructure docs (#818)
1 parent b477381 commit 1ec7adb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+337
-446
lines changed

.gitattributes

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
/benchmarks export-ignore
55
/tests export-ignore
66
/examples export-ignore
7-
/tools export-ignore
87
.codecov.yml export-ignore
98
.gitattributes export-ignore
109
.gitignore export-ignore
1110
CONTRIBUTING.md export-ignore
11+
generate-class-reference.php export-ignore
1212
mkdocs.yml export-ignore
1313
phpbench.json export-ignore
14-
phpunit.xml.dist export-ignore
14+
phpcs.xml.dist export-ignore
15+
phpstan.neon.dist export-ignore
16+
phpstan-baseline.neon export-ignore
17+
phpunit.xml.dist export-ignore

CHANGELOG.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -264,20 +264,20 @@ This release brings several breaking changes. Please refer to [UPGRADE](UPGRADE.
264264

265265
New features and notable changes:
266266
- Changed minimum PHP version from 5.4 to 5.5
267-
- Lazy loading of types without separate build step (see #69, see [docs](http://webonyx.github.io/graphql-php/type-system/schema/#lazy-loading-of-types))
268-
- PSR-7 compliant Standard Server (see [docs](http://webonyx.github.io/graphql-php/executing-queries/#using-server))
269-
- New default error formatting, which does not expose sensitive data (see [docs](http://webonyx.github.io/graphql-php/error-handling/))
270-
- Ability to define custom error handler to filter/log/re-throw exceptions after execution (see [docs](http://webonyx.github.io/graphql-php/error-handling/#custom-error-handling-and-formatting))
271-
- Allow defining schema configuration using objects with fluent setters vs array (see [docs](http://webonyx.github.io/graphql-php/type-system/schema/#using-config-class))
272-
- Allow serializing AST to array and re-creating AST from array lazily (see [docs](http://webonyx.github.io/graphql-php/reference/#graphqlutilsast))
273-
- [Apollo-style](https://dev-blog.apollodata.com/query-batching-in-apollo-63acfd859862) query batching support via server (see [docs](http://webonyx.github.io/graphql-php/executing-queries/#query-batching))
274-
- Schema validation, including validation of interface implementations (see [docs](http://webonyx.github.io/graphql-php/type-system/schema/#schema-validation))
275-
- Ability to pass custom config formatter when defining schema using [GraphQL type language](http://graphql.org/learn/schema/#type-language) (see [docs](http://webonyx.github.io/graphql-php/type-system/type-language/))
267+
- Lazy loading of types without separate build step (see #69, see [docs](https://webonyx.github.io/graphql-php/type-system/schema/#lazy-loading-of-types))
268+
- PSR-7 compliant Standard Server (see [docs](https://webonyx.github.io/graphql-php/executing-queries/#using-server))
269+
- New default error formatting, which does not expose sensitive data (see [docs](https://webonyx.github.io/graphql-php/error-handling/))
270+
- Ability to define custom error handler to filter/log/re-throw exceptions after execution (see [docs](https://webonyx.github.io/graphql-php/error-handling/#custom-error-handling-and-formatting))
271+
- Allow defining schema configuration using objects with fluent setters vs array (see [docs](https://webonyx.github.io/graphql-php/type-system/schema/#using-config-class))
272+
- Allow serializing AST to array and re-creating AST from array lazily (see [docs](https://webonyx.github.io/graphql-php/reference/#graphqlutilsast))
273+
- [Apollo-style](https://dev-blog.apollodata.com/query-batching-in-apollo-63acfd859862) query batching support via server (see [docs](https://webonyx.github.io/graphql-php/executing-queries/#query-batching))
274+
- Schema validation, including validation of interface implementations (see [docs](https://webonyx.github.io/graphql-php/type-system/schema/#schema-validation))
275+
- Ability to pass custom config formatter when defining schema using [GraphQL type language](http://graphql.org/learn/schema/#type-language) (see [docs](https://webonyx.github.io/graphql-php/type-system/type-language/))
276276

277277
Improvements:
278278
- Significantly improved parser performance (see #137 and #128)
279279
- Support for PHP7 exceptions everywhere (see #127)
280-
- Improved [documentation](http://webonyx.github.io/graphql-php/) and docblock comments
280+
- Improved [documentation](https://webonyx.github.io/graphql-php/) and docblock comments
281281

282282
Deprecations and breaking changes - see [UPGRADE](UPGRADE.md) document.
283283

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,5 @@ We document this library by rendering the Markdown files in [docs](docs) with [M
8585
Generate the class reference docs:
8686

8787
```sh
88-
composer api-docs
88+
composer docs
8989
```

UPGRADE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ GraphQL::executeAndReturnResult(/**/)
459459
But note that this is deprecated format and will be removed in future versions.
460460

461461
In general, if new default formatting doesn't work for you - just set [your own error
462-
formatter](http://webonyx.github.io/graphql-php/error-handling/#custom-error-handling-and-formatting).
462+
formatter](https://webonyx.github.io/graphql-php/error-handling/#custom-error-handling-and-formatting).
463463

464464
### Breaking: Validation rules now have abstract base class
465465
Previously any callable was accepted by DocumentValidator as validation rule. Now only instances of
@@ -561,7 +561,7 @@ See https://github.com/webonyx/graphql-php/issues/148
561561
Use [new PSR-7 compliant implementation](docs/executing-queries.md#using-server) instead.
562562

563563
### Deprecated: experimental `GraphQL\Type\Resolution` interface and implementations
564-
Use schema [**typeLoader** option](docs/type-system/schema.md#lazy-loading-of-types) instead.
564+
Use schema [**typeLoader** option](docs/schema-definition.md#lazy-loading-of-types) instead.
565565

566566
### Non-breaking: usage on async platforms
567567
When using the library on async platforms use separate method `GraphQL::promiseToExecute()`.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@
4848
}
4949
},
5050
"scripts": {
51-
"api-docs": "php tools/gendocs.php",
5251
"baseline": "phpstan --ansi --generate-baseline",
5352
"bench": "phpbench run",
5453
"check": "composer lint && composer stan && composer test",
54+
"docs": "php generate-class-reference.php",
5555
"fix": "phpcbf",
5656
"lint": "phpcs",
5757
"stan": "phpstan --ansi",

docs/index.md renamed to docs/about.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ engineers. Various implementations of this specification were written
1616
Great overview of GraphQL features and benefits is presented on [the official website](http://graphql.org/).
1717
All of them equally apply to this PHP implementation.
1818

19-
2019
# About graphql-php
2120

2221
**graphql-php** is a feature-complete implementation of GraphQL specification in PHP (5.5+, 7.0+).
@@ -29,11 +28,11 @@ are used. Instead, it provides tools for creating rich API for your existing app
2928

3029
Library features include:
3130

32-
- Primitives to express your app as a [Type System](type-system/index.md)
31+
- Primitives to express your app as a [Type System](type-definitions/introduction.md)
3332
- Validation and introspection of this Type System (for compatibility with tools like [GraphiQL](complementary-tools.md#tools))
3433
- Parsing, validating and [executing GraphQL queries](executing-queries.md) against this Type System
3534
- Rich [error reporting](error-handling.md), including query validation and execution errors
36-
- Optional tools for [parsing GraphQL Type language](type-system/type-language.md)
35+
- Optional tools for [parsing schema definition language](schema-definition-language.md)
3736
- Tools for [batching requests](data-fetching.md#solving-n1-problem) to backend storage
3837
- [Async PHP platforms support](data-fetching.md#async-php) via promises
3938
- [Standard HTTP server](executing-queries.md#using-server)
@@ -46,8 +45,8 @@ The first version of this library (v0.1) was released on August 10th 2015.
4645

4746
The current version supports all features described by GraphQL specification
4847
as well as some experimental features like
49-
[Schema Language parser](type-system/type-language.md) and
50-
[Schema printer](reference.md#graphqlutilsschemaprinter).
48+
[schema definition language](schema-definition-language.md) and
49+
[schema printer](class-reference.md#graphqlutilsschemaprinter).
5150

5251
Ready for real-world usage.
5352

docs/best-practices.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

docs/reference.md renamed to docs/class-reference.md

Lines changed: 59 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ const INPUT_FIELD_DEFINITION = "INPUT_FIELD_DEFINITION";
422422
# GraphQL\Type\SchemaConfig
423423
Schema configuration class.
424424
Could be passed directly to schema constructor. List of options accepted by **create** method is
425-
[described in docs](type-system/schema.md#configuration-options).
425+
[described in docs](type-definitions/schema-definition.md#configuration-options).
426426

427427
Usage example:
428428

@@ -549,7 +549,7 @@ function setDirectives(array $directives)
549549

550550
```php
551551
/**
552-
* @return callable(string $name):Type|null
552+
* @return callable|null
553553
*
554554
* @api
555555
*/
@@ -565,7 +565,7 @@ function getTypeLoader()
565565
function setTypeLoader(callable $typeLoader)
566566
```
567567
# GraphQL\Type\Schema
568-
Schema Definition (see [related docs](type-system/schema.md))
568+
Schema Definition (see [related docs](type-definitions/schema-definition.md))
569569

570570
A Schema is created by supplying the root types of each type of operation:
571571
query, mutation (optional) and subscription (optional). A schema definition is
@@ -601,11 +601,11 @@ function __construct($config)
601601
*
602602
* This operation requires full schema scan. Do not use in production environment.
603603
*
604-
* @return Type[]
604+
* @return array<string, Type>
605605
*
606606
* @api
607607
*/
608-
function getTypeMap()
608+
function getTypeMap(): array
609609
```
610610

611611
```php
@@ -688,17 +688,46 @@ function getPossibleTypes(GraphQL\Type\Definition\Type $abstractType): array
688688

689689
```php
690690
/**
691+
* Returns all types that implement a given interface type.
692+
*
693+
* This operations requires full schema scan. Do not use in production environment.
694+
*
695+
* @api
696+
*/
697+
function getImplementations(GraphQL\Type\Definition\InterfaceType $abstractType): GraphQL\Utils\InterfaceImplementations
698+
```
699+
700+
```php
701+
/**
702+
* @deprecated as of 14.4.0 use isSubType instead, will be removed in 15.0.0.
703+
*
691704
* Returns true if object type is concrete type of given abstract type
692705
* (implementation for interfaces and members of union type for unions)
693706
*
694707
* @api
708+
* @codeCoverageIgnore
695709
*/
696710
function isPossibleType(
697711
GraphQL\Type\Definition\AbstractType $abstractType,
698712
GraphQL\Type\Definition\ObjectType $possibleType
699713
): bool
700714
```
701715

716+
```php
717+
/**
718+
* Returns true if the given type is a sub type of the given abstract type.
719+
*
720+
* @param UnionType|InterfaceType $abstractType
721+
* @param ObjectType|InterfaceType $maybeSubType
722+
*
723+
* @api
724+
*/
725+
function isSubType(
726+
GraphQL\Type\Definition\AbstractType $abstractType,
727+
GraphQL\Type\Definition\ImplementingType $maybeSubType
728+
): bool
729+
```
730+
702731
```php
703732
/**
704733
* Returns instance of directive by name
@@ -734,7 +763,7 @@ function assertValid()
734763
function validate()
735764
```
736765
# GraphQL\Language\Parser
737-
Parses string containing GraphQL query or [type definition](type-system/type-language.md) to Abstract Syntax Tree.
766+
Parses string containing GraphQL query or [type definition](type-definitions/schema-definition-language.md) to Abstract Syntax Tree.
738767

739768
Those magic functions allow partial parsing:
740769

@@ -762,15 +791,15 @@ Those magic functions allow partial parsing:
762791
@method static NodeList<FieldDefinitionNode> fieldsDefinition(Source|string $source, bool[] $options = [])
763792
@method static NodeList<InputValueDefinitionNode> argumentsDefinition(Source|string $source, bool[] $options = [])
764793
@method static InterfaceTypeDefinitionNode interfaceTypeDefinition(Source|string $source, bool[] $options = [])
765-
@method static NamedTypeNode[] unionMemberTypes(Source|string $source, bool[] $options = [])
794+
@method static NodeList<NamedTypeNode> unionMemberTypes(Source|string $source, bool[] $options = [])
766795
@method static NodeList<EnumValueDefinitionNode> enumValuesDefinition(Source|string $source, bool[] $options = [])
767796
@method static InputObjectTypeDefinitionNode inputObjectTypeDefinition(Source|string $source, bool[] $options = [])
768797
@method static TypeExtensionNode typeExtension(Source|string $source, bool[] $options = [])
769798
@method static ScalarTypeExtensionNode scalarTypeExtension(Source|string $source, bool[] $options = [])
770799
@method static InterfaceTypeExtensionNode interfaceTypeExtension(Source|string $source, bool[] $options = [])
771800
@method static EnumTypeExtensionNode enumTypeExtension(Source|string $source, bool[] $options = [])
772801
@method static DirectiveDefinitionNode directiveDefinition(Source|string $source, bool[] $options = [])
773-
@method static DirectiveLocation directiveLocation(Source|string $source, bool[] $options = [])
802+
@method static NameNode directiveLocation(Source|string $source, bool[] $options = [])
774803

775804
**Class Methods:**
776805
```php
@@ -928,7 +957,7 @@ visit function.
928957
]);
929958

930959
Alternatively to providing enter() and leave() functions, a visitor can
931-
instead provide functions named the same as the [kinds of AST nodes](reference.md#graphqllanguageastnodekind),
960+
instead provide functions named the same as the [kinds of AST nodes](class-reference.md#graphqllanguageastnodekind),
932961
or enter/leave visitors at a named key, leading to four permutations of
933962
visitor API:
934963

@@ -1088,13 +1117,13 @@ Implements the "Evaluating requests" section of the GraphQL specification.
10881117
/**
10891118
* Executes DocumentNode against given $schema.
10901119
*
1091-
* Always returns ExecutionResult and never throws. All errors which occur during operation
1092-
* execution are collected in `$result->errors`.
1120+
* Always returns ExecutionResult and never throws.
1121+
* All errors which occur during operation execution are collected in `$result->errors`.
10931122
*
1094-
* @param mixed|null $rootValue
1095-
* @param mixed|null $contextValue
1096-
* @param mixed[]|ArrayAccess|null $variableValues
1097-
* @param string|null $operationName
1123+
* @param mixed|null $rootValue
1124+
* @param mixed|null $contextValue
1125+
* @param array<mixed>|ArrayAccess|null $variableValues
1126+
* @param string|null $operationName
10981127
*
10991128
* @return ExecutionResult|Promise
11001129
*
@@ -1118,10 +1147,10 @@ static function execute(
11181147
*
11191148
* Useful for async PHP platforms.
11201149
*
1121-
* @param mixed|null $rootValue
1122-
* @param mixed|null $contextValue
1123-
* @param mixed[]|null $variableValues
1124-
* @param string|null $operationName
1150+
* @param mixed|null $rootValue
1151+
* @param mixed|null $contextValue
1152+
* @param array<mixed>|null $variableValues
1153+
* @param string|null $operationName
11251154
*
11261155
* @return Promise
11271156
*
@@ -1343,9 +1372,9 @@ A list of specific validation rules may be provided. If not provided, the
13431372
default list of rules defined by the GraphQL specification will be used.
13441373

13451374
Each validation rule is an instance of GraphQL\Validator\Rules\ValidationRule
1346-
which returns a visitor (see the [GraphQL\Language\Visitor API](reference.md#graphqllanguagevisitor)).
1375+
which returns a visitor (see the [GraphQL\Language\Visitor API](class-reference.md#graphqllanguagevisitor)).
13471376

1348-
Visitor methods are expected to return an instance of [GraphQL\Error\Error](reference.md#graphqlerrorerror),
1377+
Visitor methods are expected to return an instance of [GraphQL\Error\Error](class-reference.md#graphqlerrorerror),
13491378
or array of such instances when invalid.
13501379

13511380
Optionally a custom TypeInfo instance may be provided. If not provided, one
@@ -1442,7 +1471,7 @@ const CATEGORY_INTERNAL = "internal";
14421471
*
14431472
* @api
14441473
*/
1445-
function getLocations()
1474+
function getLocations(): array
14461475
```
14471476

14481477
```php
@@ -1623,7 +1652,7 @@ Usage Example:
16231652
]);
16241653
$server->handleRequest();
16251654

1626-
Or using [ServerConfig](reference.md#graphqlserverserverconfig) instance:
1655+
Or using [ServerConfig](class-reference.md#graphqlserverserverconfig) instance:
16271656

16281657
$config = GraphQL\Server\ServerConfig::create()
16291658
->setSchema($mySchema)
@@ -1642,12 +1671,12 @@ See [dedicated section in docs](executing-queries.md#using-server) for details.
16421671
* (e.g. during schema instantiation).
16431672
*
16441673
* @param Throwable $error
1645-
* @param bool $debug
1674+
* @param int $debug
16461675
* @param bool $exitWhenDone
16471676
*
16481677
* @api
16491678
*/
1650-
static function send500Error($error, $debug = false, $exitWhenDone = false)
1679+
static function send500Error($error, $debug = "GraphQL\Error\DebugFlag::NONE", $exitWhenDone = false)
16511680
```
16521681

16531682
```php
@@ -2091,8 +2120,8 @@ function getOriginalInput($key)
20912120
function isReadOnly()
20922121
```
20932122
# GraphQL\Utils\BuildSchema
2094-
Build instance of `GraphQL\Type\Schema` out of type language definition (string or parsed AST)
2095-
See [section in docs](type-system/type-language.md) for details.
2123+
Build instance of `GraphQL\Type\Schema` out of schema language definition (string or parsed AST)
2124+
See [schema definition language docs](schema-definition-language.md) for details.
20962125

20972126
**Class Methods:**
20982127
```php
@@ -2101,7 +2130,7 @@ See [section in docs](type-system/type-language.md) for details.
21012130
* document.
21022131
*
21032132
* @param DocumentNode|Source|string $source
2104-
* @param bool[] $options
2133+
* @param array<string, bool> $options
21052134
*
21062135
* @return Schema
21072136
*
@@ -2127,7 +2156,7 @@ static function build($source, callable $typeConfigDecorator = null, array $opti
21272156
* Provide true to use preceding comments as the description.
21282157
* This option is provided to ease adoption and will be removed in v16.
21292158
*
2130-
* @param bool[] $options
2159+
* @param array<string, bool> $options
21312160
*
21322161
* @return Schema
21332162
*
@@ -2306,7 +2335,7 @@ static function typeFromAST(GraphQL\Type\Schema $schema, $inputTypeNode)
23062335
static function getOperation(GraphQL\Language\AST\DocumentNode $document, $operationName = null)
23072336
```
23082337
# GraphQL\Utils\SchemaPrinter
2309-
Given an instance of Schema, prints it in GraphQL type language.
2338+
Given an instance of Schema, prints it in schema definition language.
23102339

23112340
**Class Methods:**
23122341
```php

docs/concepts.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ and executes using [data fetching tools](data-fetching.md) provided by you
3939
as a part of integration. Queries are supposed to be idempotent.
4040

4141
## Mutations
42-
Mutations use advanced features of the very same query language (like arguments and variables)
43-
and have only semantic difference from Queries:
42+
Mutations are root fields that are allowed to have side effects, such as creating, updating or deleting data.
43+
In contrast to Query fields, the fields within the root Mutation type are executed serially.
44+
Otherwise, their definition and execution is identical to all other fields.
4445

4546
```graphql
4647
mutation CreateReviewForEpisode($ep: Episode!, $review: ReviewInput!) {
@@ -82,7 +83,7 @@ returned after mutation. In our example mutation will return:
8283

8384
# Type System
8485
Conceptually GraphQL type is a collection of fields. Each field in turn
85-
has it's own type which allows to build complex hierarchies.
86+
has its own type which allows building complex hierarchies.
8687

8788
Quick example on pseudo-language:
8889
```

0 commit comments

Comments
 (0)