Skip to content

Commit 65e082d

Browse files
authored
Upgrade docusaurus to v2 (#380)
* Updated and migrated from docusaurus 1.x to 2.x * Got tabs working with codeblocks * Moved docs to website/ and renamed respective MDX file extensions due to updated JSX style syntax for tabbed codeblocks * Updated links to new MDX extension * Fixed additional bugs and formatting issues * Moved filenames/titles to title attr of codeblock * Versioned 4.2 and 4.3 and fixed versioning dropdown * Added new serve command * Add CNAME config * Fix node target issue * Removed v1 npm command * Fix Github pages deployment * Delete package-lock.json
1 parent 492a045 commit 65e082d

File tree

257 files changed

+24145
-1983
lines changed

Some content is hidden

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

257 files changed

+24145
-1983
lines changed

.gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/vendor/
2-
/mouf/
32
/composer.lock
43
/src/Tests/
5-
/build/
64
/phpunit.xml
75
/.php_cs/cache
86

website/.gitignore

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# dependencies
2+
/node_modules
3+
4+
# production
5+
/build
6+
7+
# generated files
8+
.docusaurus
9+
.cache-loader
10+
11+
# misc
12+
.DS_Store
13+
.env.local
14+
.env.development.local
15+
.env.test.local
16+
.env.production.local
17+
18+
npm-debug.log*
19+
yarn-debug.log*
20+
yarn-error.log*

website/bin/deploy-github

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Checks the PHP code style with `phpcs` for a given path or file
4+
#
5+
6+
set -e
7+
8+
. $(dirname $0)/include-path
9+
10+
path="$1"
11+
12+
export GIT_USER="oojacoboo"
13+
export CURRENT_BRANCH="master"
14+
export USE_SSH=true
15+
16+
yarn docusaurus deploy

website/bin/include-path

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
export LOCAL_PATH=$(dirname $0)
4+
export PATH="$LOCAL_PATH:$PATH"

website/core/Footer.js

-29
This file was deleted.

docs/CHANGELOG.md website/docs/CHANGELOG.md

+30-32
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ title: Changelog
44
sidebar_label: Changelog
55
---
66

7-
## 4.3
7+
## 4.3.0
88

9-
Breaking change:
9+
#### Breaking change:
1010

1111
- The method `setAnnotationCacheDir($directory)` has been removed from the `SchemaFactory`. The annotation
1212
cache will use your `Psr\SimpleCache\CacheInterface` compliant cache handler set through the `SchemaFactory`
1313
constructor.
1414

15-
Minor changes:
15+
#### Minor changes:
1616

1717
- Removed dependency for doctrine/cache and unified some of the cache layers following a PSR interface.
1818
- Cleaned up some of the documentation in an attempt to get things accurate with versioned releases.
1919

20-
## 4.2
20+
## 4.2.0
2121

22-
Breaking change:
22+
#### Breaking change:
2323

2424
The method signature for `toGraphQLOutputType` and `toGraphQLInputType` have been changed to the following:
2525

@@ -35,82 +35,80 @@ public function toGraphQLOutputType(Type $type, ?OutputType $subType, $reflector
3535
public function toGraphQLInputType(Type $type, ?InputType $subType, string $argumentName, $reflector, DocBlock $docBlockObj): InputType;
3636
```
3737

38-
New features:
38+
#### New features:
3939

40-
- [@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.md#input-annotation).
41-
- New attributes has been added to [@Field](annotations_reference.md#field-annotation) annotation: `for`, `inputType` and `description`.
40+
- [@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-annotation).
41+
- New attributes has been added to [@Field](annotations-reference.md#field-annotation) annotation: `for`, `inputType` and `description`.
4242
- The following annotations now can be applied to class properties directly: `@Field`, `@Logged`, `@Right`, `@FailWith`, `@HideIfUnauthorized` and `@Security`.
4343

44-
## 4.1
44+
## 4.1.0
4545

46-
Breaking change:
46+
#### Breaking change:
4747

4848
There is one breaking change introduced in the minor version (this was important to allow PHP 8 compatibility).
4949

5050
- The **ecodev/graphql-upload** package (used to get support for file uploads in GraphQL input types) is now a "recommended" dependency only.
5151
If you are using GraphQL file uploads, you need to add `ecodev/graphql-upload` to your `composer.json`.
5252

53-
New features:
53+
#### New features:
5454

5555
- All annotations can now be accessed as PHP 8 attributes
5656
- The `@deprecated` annotation in your PHP code translates into deprecated fields in your GraphQL schema
5757
- You can now specify the GraphQL name of the Enum types you define
5858
- Added the possibility to inject pure Webonyx objects in GraphQLite schema
5959

60-
Minor changes:
60+
#### Minor changes:
6161

6262
- Migrated from `zend/diactoros` to `laminas/diactoros`
6363
- Making the annotation cache directory configurable
6464

65-
Miscellaneous:
65+
#### Miscellaneous:
6666

6767
- Migrated from Travis to Github actions
6868

69-
## 4.0
69+
70+
## 4.0.0
7071

7172
This is a complete refactoring from 3.x. While existing annotations are kept compatible, the internals have completely
7273
changed.
7374

74-
New features:
75+
#### New features:
7576

76-
- You can directly [annotate a PHP interface with `@Type` to make it a GraphQL interface](inheritance-interfaces.md#mapping-interfaces)
77+
- You can directly [annotate a PHP interface with `@Type` to make it a GraphQL interface](inheritance-interfaces.mdx#mapping-interfaces)
7778
- You can autowire services in resolvers, thanks to the new `@Autowire` annotation
78-
- Added [user input validation](validation.md) (using the Symfony Validator or the Laravel validator or a custom `@Assertion` annotation
79+
- Added [user input validation](validation.mdx) (using the Symfony Validator or the Laravel validator or a custom `@Assertion` annotation
7980
- Improved security handling:
8081
- Unauthorized access to fields can now generate GraphQL errors (rather that schema errors in GraphQLite v3)
81-
- Added fine-grained security using the `@Security` annotation. A field can now be [marked accessible or not depending on the context](fine-grained-security.md).
82+
- 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).
8283
For instance, you can restrict access to the field "viewsCount" of the type `BlogPost` only for post that the current user wrote.
8384
- You can now inject the current logged user in any query / mutation / field using the `@InjectUser` annotation
8485
- Performance:
85-
- You can inject the [Webonyx query plan in a parameter from a resolver](query_plan.md)
86-
- You can use the [dataloader pattern to improve performance drastically via the "prefetchMethod" attribute](prefetch_method.md)
86+
- You can inject the [Webonyx query plan in a parameter from a resolver](query-plan.mdx)
87+
- You can use the [dataloader pattern to improve performance drastically via the "prefetchMethod" attribute](prefetch-method.mdx)
8788
- Customizable error handling has been added:
88-
- You can throw [GraphQL errors](error_handling.md) with `TheCodingMachine\GraphQLite\Exceptions\GraphQLException`
89-
- You can specify the HTTP response code to send with a given error, and the errors "extensions" section
90-
- You can throw [many errors in one exception](error_handling.md#many-errors-for-one-exception) with `TheCodingMachine\GraphQLite\Exceptions\GraphQLAggregateException`
91-
- You can map [a given PHP class to several PHP input types](input_types.md#declaring-several-input-types-for-the-same-php-class) (a PHP class can have several `@Factory` annotations)
89+
- You can throw [many errors in one exception](error-handling.mdx#many-errors-for-one-exception) with `TheCodingMachine\GraphQLite\Exceptions\GraphQLAggregateException`
9290
- You can force input types using `@UseInputType(for="$id", inputType="ID!")`
93-
- You can extend an input types (just like you could extend an output type in v3) using [the new `@Decorate` annotation](extend_input_type.md)
94-
- In a factory, you can [exclude some optional parameters from the GraphQL schema](input_types#ignoring-some-parameters)
91+
- 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)
92+
- In a factory, you can [exclude some optional parameters from the GraphQL schema](input-types#ignoring-some-parameters)
9593

9694

9795
Many extension points have been added
9896

9997
- Added a "root type mapper" (useful to map scalar types to PHP types or to add custom annotations related to resolvers)
100-
- Added ["field middlewares"](field_middlewares.md) (useful to add middleware that modify the way GraphQL fields are handled)
101-
- Added a ["parameter type mapper"](argument_resolving.md) (useful to add customize parameter resolution or add custom annotations related to parameters)
98+
- Added ["field middlewares"](field-middlewares.md) (useful to add middleware that modify the way GraphQL fields are handled)
99+
- Added a ["parameter type mapper"](argument-resolving.md) (useful to add customize parameter resolution or add custom annotations related to parameters)
102100

103101
New framework specific features:
104102

105-
Symfony:
103+
#### Symfony:
106104

107105
- The Symfony bundle now provides a "login" and a "logout" mutation (and also a "me" query)
108106

109-
Laravel:
107+
#### Laravel:
110108

111-
- [Native integration with the Laravel paginator](laravel-package-advanced.md#support-for-pagination) has been added
109+
- [Native integration with the Laravel paginator](laravel-package-advanced.mdx#support-for-pagination) has been added
112110

113-
Internals:
111+
#### Internals:
114112

115113
- The `FieldsBuilder` class has been split in many different services (`FieldsBuilder`, `TypeHandler`, and a
116114
chain of *root type mappers*)

docs/features.md website/docs/README.mdx

+36-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
---
2-
id: features
2+
id: index
33
title: GraphQLite
4+
slug: /
45
sidebar_label: GraphQLite
56
---
67

8+
import Tabs from '@theme/Tabs';
9+
import TabItem from '@theme/TabItem';
10+
711
<p align="center">
812
<img src="https://graphqlite.thecodingmachine.io/img/logo.svg" alt="GraphQLite logo" width="250" height="250" />
913
</p>
@@ -21,8 +25,14 @@ A PHP library that allows you to write your GraphQL queries in simple-to-write c
2125

2226
First, declare a query in your controller:
2327

24-
<!--DOCUSAURUS_CODE_TABS-->
25-
<!--PHP 8+-->
28+
<Tabs
29+
defaultValue="php8"
30+
values={[
31+
{label: 'PHP 8', value: 'php8'},
32+
{label: 'PHP 7', value: 'php7'},
33+
]}>
34+
<TabItem value="php8">
35+
2636
```php
2737
class ProductController
2838
{
@@ -33,7 +43,10 @@ class ProductController
3343
}
3444
}
3545
```
36-
<!--PHP 7+-->
46+
47+
</TabItem>
48+
<TabItem value="php7">
49+
3750
```php
3851
class ProductController
3952
{
@@ -46,12 +59,20 @@ class ProductController
4659
}
4760
}
4861
```
49-
<!--END_DOCUSAURUS_CODE_TABS-->
62+
63+
</TabItem>
64+
</Tabs>
5065

5166
Then, annotate the `Product` class to declare what fields are exposed to the GraphQL API:
5267

53-
<!--DOCUSAURUS_CODE_TABS-->
54-
<!--PHP 8+-->
68+
<Tabs
69+
defaultValue="php8"
70+
values={[
71+
{label: 'PHP 8', value: 'php8'},
72+
{label: 'PHP 7', value: 'php7'},
73+
]}>
74+
<TabItem value="php8">
75+
5576
```php
5677
#[Type]
5778
class Product
@@ -64,7 +85,10 @@ class Product
6485
// ...
6586
}
6687
```
67-
<!--PHP 7+-->
88+
89+
</TabItem>
90+
<TabItem value="php7">
91+
6892
```php
6993
/**
7094
* @Type()
@@ -81,11 +105,13 @@ class Product
81105
// ...
82106
}
83107
```
84-
<!--END_DOCUSAURUS_CODE_TABS-->
108+
109+
</TabItem>
110+
</Tabs>
85111

86112
That's it, you're good to go! Query and enjoy!
87113

88-
```grapql
114+
```graphql
89115
{
90116
product(id: 42) {
91117
name

0 commit comments

Comments
 (0)