Skip to content

Commit c5d4e9c

Browse files
authored
Improved docs for accuracy (#457)
1 parent 44587d3 commit c5d4e9c

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

website/docs/internals.md

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ graph TD;
2121
classDef custom fill:#cfc,stroke:#7a7,stroke-width:2px,stroke-dasharray: 5, 5;
2222
subgraph RootTypeMapperInterface
2323
NullableTypeMapperAdapter-->CompoundTypeMapper
24-
CompoundTypeMapper-->IteratorTypeMapper
2524
IteratorTypeMapper-->YourCustomRootTypeMapper
25+
CompoundTypeMapper-->IteratorTypeMapper
2626
YourCustomRootTypeMapper-->MyCLabsEnumTypeMapper
27-
MyCLabsEnumTypeMapper-->BaseTypeMapper
27+
MyCLabsEnumTypeMapper-->EnumTypeMapper
28+
EnumTypeMapper-->BaseTypeMapper
2829
BaseTypeMapper-->FinalRootTypeMapper
2930
end
3031
subgraph RecursiveTypeMapperInterface
@@ -46,23 +47,24 @@ These type mappers are the first type mappers called.
4647

4748
They are responsible for:
4849

49-
- mapping scalar types (for instance mapping the "int" PHP type to GraphQL Integer type)
50-
- detecting nullable/non-nullable types (for instance interpreting "?int" or "int|null")
51-
- mapping list types (mapping a PHP array to a GraphQL list)
52-
- mapping union types
53-
- mapping enums
50+
- mapping scalar types (for instance mapping the "int" PHP type to GraphQL Integer type)
51+
- detecting nullable/non-nullable types (for instance interpreting "?int" or "int|null")
52+
- mapping list types (mapping a PHP array to a GraphQL list)
53+
- mapping union types
54+
- mapping enums
5455

5556
Root type mappers have access to the *context* of a type: they can access the PHP DocBlock and read annotations.
5657
If you want to write a custom type mapper that needs access to annotations, it needs to be a "root type mapper".
5758

5859
GraphQLite provides 6 classes implementing `RootTypeMapperInterface`:
5960

60-
- `NullableTypeMapperAdapter`: a type mapper in charge of making GraphQL types non-nullable if the PHP type is non-nullable
61-
- `CompoundTypeMapper`: a type mapper in charge of union types
62-
- `IteratorTypeMapper`: a type mapper in charge of iterable types (for instance: `MyIterator|User[]`)
63-
- `MyCLabsEnumTypeMapper`: maps MyCLabs/enum types to GraphQL enum types
64-
- `BaseTypeMapper`: maps scalar types and lists. Passes the control to the "recursive type mappers" if an object is encountered.
65-
- `FinalRootTypeMapper`: the last type mapper of the chain, used to throw error if no other type mapper managed to handle the type.
61+
- `NullableTypeMapperAdapter`: a type mapper in charge of making GraphQL types non-nullable if the PHP type is non-nullable
62+
- `IteratorTypeMapper`: a type mapper in charge of iterable types (for instance: `MyIterator|User[]`)
63+
- `CompoundTypeMapper`: a type mapper in charge of union types
64+
- `MyCLabsEnumTypeMapper`: maps MyCLabs/enum types to GraphQL enum types (Deprecated: use native enums)
65+
- `EnumTypeMapper`: maps PHP enums to GraphQL enum types
66+
- `BaseTypeMapper`: maps scalar types and lists. Passes the control to the "recursive type mappers" if an object is encountered.
67+
- `FinalRootTypeMapper`: the last type mapper of the chain, used to throw error if no other type mapper managed to handle the type.
6668

6769
Type mappers are organized in a chain; each type-mapper is responsible for calling the next type mapper.
6870

@@ -74,13 +76,13 @@ graph TD;
7476
CompoundTypeMapper-->IteratorTypeMapper
7577
IteratorTypeMapper-->YourCustomRootTypeMapper
7678
YourCustomRootTypeMapper-->MyCLabsEnumTypeMapper
77-
MyCLabsEnumTypeMapper-->BaseTypeMapper
79+
MyCLabsEnumTypeMapper-->EnumTypeMapper
80+
EnumTypeMapper-->BaseTypeMapper
7881
BaseTypeMapper-->FinalRootTypeMapper
7982
end
8083
class YourCustomRootTypeMapper custom;
8184
```
8285

83-
8486
## Class type mappers
8587

8688
(Classes implementing the [`TypeMapperInterface`](https://github.com/thecodingmachine/graphqlite/blob/master/src/Mappers/TypeMapperInterface.php))
@@ -89,9 +91,9 @@ Class type mappers are mapping PHP classes to GraphQL object types.
8991

9092
GraphQLite provide 3 default implementations:
9193

92-
- `CompositeTypeMapper`: a type mapper that delegates mapping to other type mappers using the Composite Design Pattern.
93-
- `GlobTypeMapper`: scans classes in a directory for the `@Type` or `@ExtendType` annotation and maps those to GraphQL types
94-
- `PorpaginasTypeMapper`: maps and class implementing the Porpaginas `Result` interface to a [special paginated type](pagination.mdx).
94+
- `CompositeTypeMapper`: a type mapper that delegates mapping to other type mappers using the Composite Design Pattern.
95+
- `GlobTypeMapper`: scans classes in a directory for the `@Type` or `@ExtendType` annotation and maps those to GraphQL types
96+
- `PorpaginasTypeMapper`: maps and class implementing the Porpaginas `Result` interface to a [special paginated type](pagination.mdx).
9597

9698
### Registering a type mapper in Symfony
9799

@@ -135,5 +137,6 @@ that implements the [`ParameterMiddlewareInterface`](https://github.com/thecodin
135137
You can register your own parameter middlewares using the `SchemaFactory::addParameterMiddleware()` method, or by tagging the
136138
service as "graphql.parameter_middleware" if you are using the Symfony bundle.
137139

138-
<div class="alert alert--info">Use a parameter middleware if you want to inject an argument in a method and if this argument
139-
is not a GraphQL input type or if you want to alter the way input types are imported (for instance if you want to add a validation step)</div>
140+
<div class="alert alert--info">
141+
Use a parameter middleware if you want to inject an argument in a method and if this argument is not a GraphQL input type or if you want to alter the way input types are imported (for instance if you want to add a validation step)
142+
</div>

0 commit comments

Comments
 (0)