Skip to content

Commit eed7f24

Browse files
authored
Version 6.0 Release (#483)
* Update docs for #466 * Upgrade to use node 18 for CI * Upgrade Docusaurus * Added README for docs development and versioning * Versioned docs for 6.0 release
1 parent 8078bc2 commit eed7f24

Some content is hidden

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

44 files changed

+7818
-20
lines changed

.github/workflows/doc_generation.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: "Setup NodeJS"
2525
uses: actions/setup-node@v3
2626
with:
27-
node-version: '14.x'
27+
node-version: '18.x'
2828

2929
- name: "Yarn install"
3030
run: yarn install

website/README

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# GraphQLite Website
2+
3+
The GraphQLite website is primarily a documentation site for GraphQLite. It's built on the Docusaurus framework, and is hosted on [GitHub](https://graphqlite.thecodingmachine.io/).
4+
5+
More details on using Docusaurus can be found in the [official documentation](https://docusaurus.io/docs/docs-introduction).
6+
7+
*This documentation could use further updating.*
8+
9+
## Developing and Testing
10+
11+
All code changes, aside from errors in previous documentation, should be done in the `docs` directory. The `package.json` file outlines available commands you can use for starting the server, building the docs, etc.
12+
13+
- `npm run build` *(Transpiles/builds `docs` into `build` directory)*
14+
- `npm run start` *(Starts the local npm server)*
15+
16+
## Versioning
17+
18+
Firstly, doc versions are cached in the `versioned_docs` directory. Meanwhile, the "Next" version, as represented on the website, is the current `master` branch of the `docs` dir. A list of the versions available is actually managed by the `versions.json` file, regardless of the `versioned_docs` directory.
19+
20+
The [versioning section of the Docusaurus documentation](https://docusaurus.io/docs/versioning) covers this is more detail, but the following is related to our specific implementation:
21+
22+
### Steps to Create and Deploy a new Version
23+
24+
*All command paths are relative to the `website` directory. Ensure that you have `./node_modules/.bin` added to your path.*
25+
26+
1. Firstly, we need to tag a new version, which will cache a copy of the documentation in the `versioned_docs` directory, update the `versioned_sidebars`, and update the `versions.json` file.
27+
28+
```bash
29+
$ docusaurus docs:version 1.1
30+
```
31+
*Be sure to include the X.X in the version, not just X.*
32+
2. Technically, you're done, just commit these changes and the CI workflow will deploy when merged into `master`.

website/docs/input-types.mdx

+37-6
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ Using the `#[Input]` attribute, we can transform the `Location` class, in the ex
128128
class Location
129129
{
130130

131+
#[Field]
132+
private ?string $name = null;
133+
131134
#[Field]
132135
private float $latitude;
133136

@@ -140,6 +143,11 @@ class Location
140143
$this->longitude = $longitude;
141144
}
142145

146+
public function setName(string $name): void
147+
{
148+
$this->name = $name;
149+
}
150+
143151
public function getLatitude(): float
144152
{
145153
return $this->latitude;
@@ -162,6 +170,12 @@ class Location
162170
class Location
163171
{
164172

173+
/**
174+
* @Field
175+
* @var string|null
176+
*/
177+
private ?string $name = null;
178+
165179
/**
166180
* @Field
167181
* @var float
@@ -180,6 +194,11 @@ class Location
180194
$this->longitude = $longitude;
181195
}
182196

197+
public function setName(string $name): void
198+
{
199+
$this->name = $name;
200+
}
201+
183202
public function getLatitude(): float
184203
{
185204
return $this->latitude;
@@ -199,13 +218,13 @@ Now if you call the `getCities` query, from the controller in the first example,
199218

200219
There are some important things to notice:
201220

202-
- The `@Field` annotation is recognized only on properties for Input Type, not methods.
221+
- The `@Field` annotation is recognized on properties for Input Type, as well as setters.
203222
- There are 3 ways for fields to be resolved:
204223
- Via constructor if corresponding properties are mentioned as parameters with the same names - exactly as in the example above.
205224
- If properties are public, they will be just set without any additional effort - no constructor required.
206-
- For private or protected properties implemented, a public setter is required (if they are not set via the constructor). For example `setLatitude(float $latitude)`.
225+
- For private or protected properties implemented, a public setter is required (if they are not set via the constructor). For example `setLatitude(float $latitude)`. You can also put the `@Field` annotation on the setter, instead of the property, allowing you to have use many other attributes (`Security`, `Right`, `Autowire`, etc.).
207226
- For validation of these Input Types, see the [Custom InputType Validation section](validation#custom-inputtype-validation).
208-
- We advise using the `#[Input]` attribute on DTO style input type objects and not directly on your model objects. Using it on your model objects can cause coupling in undesirable ways.
227+
- It's advised to use the `#[Input]` attribute on DTO style input type objects and not directly on your model objects. Using it on your model objects can cause coupling in undesirable ways.
209228

210229
### Multiple Input Types from the same class
211230

@@ -239,8 +258,14 @@ class UserInput
239258
#[Field(for: 'UpdateUserInput', inputType: 'String')]
240259
public string $password;
241260

261+
protected ?int $age;
262+
263+
242264
#[Field]
243-
public ?int $age;
265+
public function setAge(?int $age): void
266+
{
267+
$this->age = $age;
268+
}
244269
}
245270
```
246271

@@ -274,11 +299,17 @@ class UserInput
274299
*/
275300
public $password;
276301

302+
/** @var int|null */
303+
protected $age;
304+
277305
/**
278306
* @Field()
279-
* @var int|null
307+
* @param int|null $age
280308
*/
281-
public $age;
309+
public function setAge(?int $age): void
310+
{
311+
$this->age = $age;
312+
}
282313
}
283314
```
284315

website/docusaurus.config.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ module.exports={
4343
"blog": {},
4444
"theme": {
4545
"customCss": "/src/css/custom.css"
46+
},
47+
"gtag": {
48+
"trackingID": "UA-10196481-8"
4649
}
4750
}
4851
]
@@ -82,13 +85,10 @@ module.exports={
8285
"href": 'https://github.com/thecodingmachine/graphqlite',
8386
}
8487
},
85-
"algolia": {
86-
"apiKey": "8fcce617e281864dc03c68d17f6206db",
87-
"indexName": "graphqlite_thecodingmachine",
88-
"algoliaOptions": {}
89-
},
90-
"gtag": {
91-
"trackingID": "UA-10196481-8"
92-
}
88+
// "algolia": {
89+
// "apiKey": "8fcce617e281864dc03c68d17f6206db",
90+
// "indexName": "graphqlite_thecodingmachine",
91+
// "algoliaOptions": {}
92+
// }
9393
}
9494
}

website/package.json

+4-5
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
"swizzle": "docusaurus swizzle",
77
"deploy": "bin/deploy-github"
88
},
9-
"devDependencies": {
10-
},
9+
"devDependencies": {},
1110
"dependencies": {
12-
"@docusaurus/core": "2.0.0-beta.14",
13-
"@docusaurus/preset-classic": "2.0.0-beta.14",
11+
"@docusaurus/core": "2.0.0-beta.21",
12+
"@docusaurus/preset-classic": "2.0.0-beta.21",
1413
"clsx": "^1.1.1",
15-
"mdx-mermaid": "^1.1.0",
14+
"mdx-mermaid": "^1.2.3",
1615
"mermaid": "^8.12.0",
1716
"react": "^17.0.1",
1817
"react-dom": "^17.0.1"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
---
2+
id: changelog
3+
title: Changelog
4+
sidebar_label: Changelog
5+
---
6+
7+
## 5.0.0
8+
9+
#### Dependencies:
10+
11+
- Upgraded to using version 14.9 of [webonyx/graphql-php](https://github.com/webonyx/graphql-php)
12+
13+
## 4.3.0
14+
15+
#### Breaking change:
16+
17+
- The method `setAnnotationCacheDir($directory)` has been removed from the `SchemaFactory`. The annotation
18+
cache will use your `Psr\SimpleCache\CacheInterface` compliant cache handler set through the `SchemaFactory`
19+
constructor.
20+
21+
#### Minor changes:
22+
23+
- Removed dependency for doctrine/cache and unified some of the cache layers following a PSR interface.
24+
- Cleaned up some of the documentation in an attempt to get things accurate with versioned releases.
25+
26+
## 4.2.0
27+
28+
#### Breaking change:
29+
30+
The method signature for `toGraphQLOutputType` and `toGraphQLInputType` have been changed to the following:
31+
32+
```php
33+
/**
34+
* @param \ReflectionMethod|\ReflectionProperty $reflector
35+
*/
36+
public function toGraphQLOutputType(Type $type, ?OutputType $subType, $reflector, DocBlock $docBlockObj): OutputType;
37+
38+
/**
39+
* @param \ReflectionMethod|\ReflectionProperty $reflector
40+
*/
41+
public function toGraphQLInputType(Type $type, ?InputType $subType, string $argumentName, $reflector, DocBlock $docBlockObj): InputType;
42+
```
43+
44+
#### New features:
45+
46+
- [@Input](annotations-reference.md#input-annotation) annotation is introduced as an alternative to `@Factory`. Now GraphQL input type can be created in the same manner as `@Type` in combination with `@Field` - [example](input-types.mdx#input-attribute).
47+
- New attributes has been added to [@Field](annotations-reference.md#field-annotation) annotation: `for`, `inputType` and `description`.
48+
- The following annotations now can be applied to class properties directly: `@Field`, `@Logged`, `@Right`, `@FailWith`, `@HideIfUnauthorized` and `@Security`.
49+
50+
## 4.1.0
51+
52+
#### Breaking change:
53+
54+
There is one breaking change introduced in the minor version (this was important to allow PHP 8 compatibility).
55+
56+
- The **ecodev/graphql-upload** package (used to get support for file uploads in GraphQL input types) is now a "recommended" dependency only.
57+
If you are using GraphQL file uploads, you need to add `ecodev/graphql-upload` to your `composer.json`.
58+
59+
#### New features:
60+
61+
- All annotations can now be accessed as PHP 8 attributes
62+
- The `@deprecated` annotation in your PHP code translates into deprecated fields in your GraphQL schema
63+
- You can now specify the GraphQL name of the Enum types you define
64+
- Added the possibility to inject pure Webonyx objects in GraphQLite schema
65+
66+
#### Minor changes:
67+
68+
- Migrated from `zend/diactoros` to `laminas/diactoros`
69+
- Making the annotation cache directory configurable
70+
71+
#### Miscellaneous:
72+
73+
- Migrated from Travis to Github actions
74+
75+
76+
## 4.0.0
77+
78+
This is a complete refactoring from 3.x. While existing annotations are kept compatible, the internals have completely
79+
changed.
80+
81+
#### New features:
82+
83+
- You can directly [annotate a PHP interface with `@Type` to make it a GraphQL interface](inheritance-interfaces.mdx#mapping-interfaces)
84+
- You can autowire services in resolvers, thanks to the new `@Autowire` annotation
85+
- Added [user input validation](validation.mdx) (using the Symfony Validator or the Laravel validator or a custom `@Assertion` annotation
86+
- Improved security handling:
87+
- Unauthorized access to fields can now generate GraphQL errors (rather that schema errors in GraphQLite v3)
88+
- Added fine-grained security using the `@Security` annotation. A field can now be [marked accessible or not depending on the context](fine-grained-security.mdx).
89+
For instance, you can restrict access to the field "viewsCount" of the type `BlogPost` only for post that the current user wrote.
90+
- You can now inject the current logged user in any query / mutation / field using the `@InjectUser` annotation
91+
- Performance:
92+
- You can inject the [Webonyx query plan in a parameter from a resolver](query-plan.mdx)
93+
- You can use the [dataloader pattern to improve performance drastically via the "prefetchMethod" attribute](prefetch-method.mdx)
94+
- Customizable error handling has been added:
95+
- You can throw [many errors in one exception](error-handling.mdx#many-errors-for-one-exception) with `TheCodingMachine\GraphQLite\Exceptions\GraphQLAggregateException`
96+
- You can force input types using `@UseInputType(for="$id", inputType="ID!")`
97+
- You can extend an input types (just like you could extend an output type in v3) using [the new `@Decorate` annotation](extend-input-type.mdx)
98+
- In a factory, you can [exclude some optional parameters from the GraphQL schema](input-types#ignoring-some-parameters)
99+
100+
101+
Many extension points have been added
102+
103+
- Added a "root type mapper" (useful to map scalar types to PHP types or to add custom annotations related to resolvers)
104+
- Added ["field middlewares"](field-middlewares.md) (useful to add middleware that modify the way GraphQL fields are handled)
105+
- Added a ["parameter type mapper"](argument-resolving.md) (useful to add customize parameter resolution or add custom annotations related to parameters)
106+
107+
New framework specific features:
108+
109+
#### Symfony:
110+
111+
- The Symfony bundle now provides a "login" and a "logout" mutation (and also a "me" query)
112+
113+
#### Laravel:
114+
115+
- [Native integration with the Laravel paginator](laravel-package-advanced.mdx#support-for-pagination) has been added
116+
117+
#### Internals:
118+
119+
- The `FieldsBuilder` class has been split in many different services (`FieldsBuilder`, `TypeHandler`, and a
120+
chain of *root type mappers*)
121+
- The `FieldsBuilderFactory` class has been completely removed.
122+
- Overall, there is not much in common internally between 4.x and 3.x. 4.x is much more flexible with many more hook points
123+
than 3.x. Try it out!

0 commit comments

Comments
 (0)