Skip to content

Commit

Permalink
docs: Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
LastDragon-ru authored Mar 8, 2024
2 parents c0702c8 + f4ddad0 commit fff2723
Show file tree
Hide file tree
Showing 65 changed files with 1,796 additions and 83 deletions.
17 changes: 15 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,21 @@
"psr-4": {
"LastDragon_ru\\LaraASP\\Dev\\App\\": "dev/App",
"LastDragon_ru\\LaraASP\\Dev\\PhpStan\\": "dev/PhpStan",
"Larastan\\Larastan\\": "dev/Larastan"
}
"Larastan\\Larastan\\": "dev/Larastan",
"LastDragon_ru\\LaraASP\\Core\\Docs\\": "packages/core/docs",
"LastDragon_ru\\LaraASP\\Documentator\\Docs\\": "packages/documentator/docs",
"LastDragon_ru\\LaraASP\\Eloquent\\Docs\\": "packages/eloquent/docs",
"LastDragon_ru\\LaraASP\\Formatter\\Docs\\": "packages/formatter/docs",
"LastDragon_ru\\LaraASP\\GraphQL\\Docs\\": "packages/graphql/docs",
"LastDragon_ru\\LaraASP\\GraphQLPrinter\\Docs\\": "packages/graphql-printer/docs",
"LastDragon_ru\\LaraASP\\Migrator\\Docs\\": "packages/migrator/docs",
"LastDragon_ru\\LaraASP\\Serializer\\Docs\\": "packages/serializer/docs",
"LastDragon_ru\\LaraASP\\Spa\\Docs\\": "packages/spa/docs",
"LastDragon_ru\\LaraASP\\Testing\\Docs\\": "packages/testing/docs"
},
"exclude-from-classmap": [
"packages/*/docs"
]
},
"extra": {
"laravel": {
Expand Down
8 changes: 8 additions & 0 deletions packages/core/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
"src/Testing/**.php"
]
},
"autoload-dev": {
"psr-4": {
"LastDragon_ru\\LaraASP\\Core\\Docs\\": "docs"
},
"exclude-from-classmap": [
"docs/"
]
},
"extra": {
"lara-asp": {
"ci": {
Expand Down
2 changes: 2 additions & 0 deletions packages/core/docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
3 changes: 3 additions & 0 deletions packages/core/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
<testsuites>
<testsuite name="package">
<directory suffix="Test.php">./src</directory>
<directory suffix="Test.php">./docs</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">./src</directory>
<directory suffix=".php">./docs</directory>
</include>
<exclude>
<directory suffix="Test.php">./src</directory>
<directory suffix="Test.php">./docs</directory>
</exclude>
</source>
<coverage cacheDirectory=".phpunit/coverage.cache"/>
Expand Down
8 changes: 8 additions & 0 deletions packages/documentator/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@
"src/Testing/**.php"
]
},
"autoload-dev": {
"psr-4": {
"LastDragon_ru\\LaraASP\\Documentator\\Docs\\": "docs"
},
"exclude-from-classmap": [
"docs/"
]
},
"extra": {
"laravel": {
"providers": [
Expand Down
3 changes: 3 additions & 0 deletions packages/documentator/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
<testsuites>
<testsuite name="package">
<directory suffix="Test.php">./src</directory>
<directory suffix="Test.php">./docs</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">./src</directory>
<directory suffix=".php">./docs</directory>
</include>
<exclude>
<directory suffix="Test.php">./src</directory>
<directory suffix="Test.php">./docs</directory>
</exclude>
</source>
<coverage cacheDirectory=".phpunit/coverage.cache"/>
Expand Down
8 changes: 8 additions & 0 deletions packages/eloquent/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@
"src/Testing/**.php"
]
},
"autoload-dev": {
"psr-4": {
"LastDragon_ru\\LaraASP\\Eloquent\\Docs\\": "docs"
},
"exclude-from-classmap": [
"docs/"
]
},
"extra": {
"lara-asp": {
"ci": {
Expand Down
2 changes: 2 additions & 0 deletions packages/eloquent/docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
3 changes: 3 additions & 0 deletions packages/eloquent/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
<testsuites>
<testsuite name="package">
<directory suffix="Test.php">./src</directory>
<directory suffix="Test.php">./docs</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">./src</directory>
<directory suffix=".php">./docs</directory>
</include>
<exclude>
<directory suffix="Test.php">./src</directory>
<directory suffix="Test.php">./docs</directory>
</exclude>
</source>
<coverage cacheDirectory=".phpunit/coverage.cache"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\TestCase;
use Illuminate\Support\Facades\Schema;
use PHPUnit\Framework\Attributes\Before;

/**
* @internal
Expand All @@ -15,10 +16,10 @@ trait WithTestObject {
use RefreshDatabase;

/**
* @before
* @internal
*/
public function initWithTestObject(): void {
#[Before]
protected function initWithTestObject(): void {
$this->afterApplicationCreated(static function (): void {
$table = (new TestObject())->getTable();

Expand Down
8 changes: 8 additions & 0 deletions packages/formatter/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@
"src/Testing/**.php"
]
},
"autoload-dev": {
"psr-4": {
"LastDragon_ru\\LaraASP\\Formatter\\Docs\\": "docs"
},
"exclude-from-classmap": [
"docs/"
]
},
"extra": {
"laravel": {
"providers": [
Expand Down
3 changes: 3 additions & 0 deletions packages/formatter/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
<testsuites>
<testsuite name="package">
<directory suffix="Test.php">./src</directory>
<directory suffix="Test.php">./docs</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">./src</directory>
<directory suffix=".php">./docs</directory>
</include>
<exclude>
<directory suffix="Test.php">./src</directory>
<directory suffix="Test.php">./docs</directory>
</exclude>
</source>
<coverage cacheDirectory=".phpunit/coverage.cache"/>
Expand Down
31 changes: 21 additions & 10 deletions packages/graphql-printer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ composer require lastdragon-ru/lara-asp-graphql-printer

[//]: # (end: dcf3043aff3a50970117872a9bba432cb3ef84a034a0fc88bcdc6d9dcae2ec06)

## Usage
# Usage

There are two primary methods: `Printer::print()` and `Printer::export()`. The `print()` will print the current type only, meanwhile `export()` will print the current type and all used types/directives:

Expand Down Expand Up @@ -115,15 +115,15 @@ type B

[//]: # (end: 25c8cf0ee2862aeda3cd8ff6bf8d2d3592fee1c00042550be5ee7686ead4cc44)

## Customization
# Customization

Please see:

* [`Settings`](./src/Settings) directory to see built-in settings;
* [`Settings`](./src/Contracts/Settings.php) interface to see all supported settings;
* [`DirectiveResolver`](./src/Contracts/DirectiveResolver.php) interface to define your own way to find all available directives and their definitions;

## Filtering
# Filtering

The Printer allows filter out types and directives. This may be useful to exclude them from the schema completely. Filtering also works for queries. Please note that types filtering will work only if the schema is known (the schema is required to determine the type of argument nodes). For some AST node types, their type may also be required.

Expand Down Expand Up @@ -213,18 +213,29 @@ query {

[//]: # (end: 292c33ba589c3d1a9a6b77c55aad173396a11c5fed1da07af456c995f3f55838)

## Laravel/Lighthouse
# Laravel/Lighthouse

It is highly recommended to use [`lara-asp-graphql`][pkg:graphql#Printer] package to use the `Printer` within the Laravel/Lighthouse application.

## Testing Assertions
# Testing Assertions

Package also provides few great [GraphQL Assertions](./src/Testing/GraphQLAssertions.php):
[include:document-list]: ./docs/Assertions
[//]: # (start: 86d73ad55f2c494dfe35350837400088c82dfa7457eafd0d30392ba96bbbdc9a)
[//]: # (warning: Generated automatically. Do not edit.)

## `assertGraphQLExportableEquals`

Exports and compares two GraphQL schemas/types/nodes/etc.

[Read more](<docs/Assertions/AssertGraphQLExportableEquals.md>).

## `assertGraphQLPrintableEquals`

Prints and compares two GraphQL schemas/types/nodes/etc.

[Read more](<docs/Assertions/AssertGraphQLPrintableEquals.md>).

| Name | Description |
|---------------------------------|-----------------------------------------------------------|
| `assertGraphQLPrintableEquals` | Prints and compares two GraphQL schemas/types/nodes/etc. |
| `assertGraphQLExportableEquals` | Exports and compares two GraphQL schemas/types/nodes/etc. |
[//]: # (end: 86d73ad55f2c494dfe35350837400088c82dfa7457eafd0d30392ba96bbbdc9a)

[include:file]: ../../docs/Shared/Upgrading.md
[//]: # (start: e9139abedb89f69284102c9112b548fd7add07cf196259916ea4f1c98977223b)
Expand Down
8 changes: 8 additions & 0 deletions packages/graphql-printer/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
"src/Testing/**.php"
]
},
"autoload-dev": {
"psr-4": {
"LastDragon_ru\\LaraASP\\GraphQLPrinter\\Docs\\": "docs"
},
"exclude-from-classmap": [
"docs/"
]
},
"config": {
"sort-packages": true,
"optimize-autoloader": true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# `assertGraphQLExportableEquals`

Exports and compares two GraphQL schemas/types/nodes/etc.

[include:example]: ./AssertGraphQLExportableEqualsTest.php
[//]: # (start: 133d4e1cb1ecae97bc0bc725a805d078526526302c85ce377f2d8494690c3070)
[//]: # (warning: Generated automatically. Do not edit.)

```php
<?php declare(strict_types = 1);

namespace LastDragon_ru\LaraASP\GraphQLPrinter\Docs\Assertions;

use GraphQL\Utils\BuildSchema;
use LastDragon_ru\LaraASP\GraphQLPrinter\Testing\GraphQLAssertions;
use LastDragon_ru\LaraASP\GraphQLPrinter\Testing\GraphQLExpected;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\TestCase;

/**
* @internal
*/
#[CoversNothing]
final class AssertGraphQLExportableEqualsTest extends TestCase {
/**
* Trait where assertion defined.
*/
use GraphQLAssertions;

/**
* Assertion test.
*/
public function testAssertion(): void {
// Prepare
$schema = BuildSchema::build(
<<<'GRAPHQL'
directive @a(b: B) on OBJECT

type Query {
a: A
}

type A @a {
id: ID!
}

input B {
b: String!
}
GRAPHQL,
);
$type = $schema->getType('A');
$expected = <<<'GRAPHQL'
type A
@a
{
id: ID!
}

directive @a(
b: B
)
on
| OBJECT

input B {
b: String!
}

GRAPHQL;

self::assertNotNull($type);

// Test
// (schema required to find types/directives definition)
$this->assertGraphQLExportableEquals(
(new GraphQLExpected($expected))->setSchema($schema),
$type,
);
}
}
```

[//]: # (end: 133d4e1cb1ecae97bc0bc725a805d078526526302c85ce377f2d8494690c3070)
Loading

0 comments on commit fff2723

Please sign in to comment.