Skip to content

Commit

Permalink
Merge pull request #9 from andrey-mokhov/prepare-release
Browse files Browse the repository at this point in the history
prepare release
  • Loading branch information
andrey-mokhov committed Dec 11, 2023
2 parents ea2d404 + 2e01aa1 commit ddc2513
Show file tree
Hide file tree
Showing 9 changed files with 166 additions and 17 deletions.
15 changes: 8 additions & 7 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/.github export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/phpunit.xml.dist export-ignore
/tests export-ignore
/.editorconfig export-ignore
/psalm.xml.dist export-ignore
/.github export-ignore
/tests export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.styleci.yml export-ignore
/phpunit.xml.dist export-ignore
/psalm.xml.dist export-ignore
139 changes: 139 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: build

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
security:
name: Security
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
php: [ '8.3' ] # Note: This workflow requires only the LATEST version of PHP
os: [ ubuntu-latest ]
stability: [prefer-stable]

steps:
# General Steps
- name: Set Git To Use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v3

- name: Validate composer.json
run: composer validate --strict

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install dependencies
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress

# Execution
- name: Security Advisories
run: composer require --dev roave/security-advisories:dev-latest
static-analysis:
name: Psalm
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
php: ['8.3'] # Note: This workflow requires only the LATEST version of PHP
os: [ubuntu-latest]
stability: [prefer-stable]

steps:
# General Steps
- name: Set Git To Use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v3

- name: Validate composer.json
run: composer validate --strict

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install dependencies
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress

# Execution
- name: Static Analysis
run: |
vendor/bin/psalm --no-cache --shepherd --stats --output-format=checkstyle --php-version=${{ matrix.php }}
test:
name: Build (${{matrix.php}}, ${{ matrix.os }}, ${{ matrix.stability }})
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
php: ['8.1', '8.2', '8.3']
os: [ubuntu-latest]
stability: [prefer-lowest, prefer-stable]

steps:
- name: Set Git To Use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v3

- name: Validate composer.json
run: composer validate --strict

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install dependencies
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress

# Execution
- name: Execute Tests
run: XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-clover=coverage.clover
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# GraphQL library for Spiral Framework

The library integrates the GraphQL library
[andi-lab/graphql-php](https://packagist.org/packages/andi-lab/graphql-php) with
[SpiralFramework](https://packagist.org/packages/spiral/framework).


# roadmap
## Roadmap

release 0.1

- [x] Enum loader
- [x] Interface loader
- [ ] configure package: `.editorconfig`, `.gitattributes`, `.styleci.yml`, `phpunit.xml`, `psalm.xml`
- [x] configure package: `.editorconfig`, `.gitattributes`, `.styleci.yml`, `phpunit.xml`, `psalm.xml`

release 1.0
- [ ] Clear memory after GraphQL schema initialization
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"type": "library",
"require": {
"php": "^8.1",
"andi-lab/graphql-php": "*",
"andi-lab/graphql-php": "^1.0",
"spiral/framework": "^3.8.4"
},
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion psalm.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
errorLevel="4"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
Expand Down
9 changes: 6 additions & 3 deletions src/Bootloader/GraphQLBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use Andi\GraphQL\TypeResolver\TypeResolverInterface;
use GraphQL\Server\ServerConfig;
use GraphQL\Server\StandardServer;
use GraphQL\Type\Definition as Webonyx;
use GraphQL\Type\Schema;
use GraphQL\Type\SchemaConfig;
use Psr\Container\ContainerInterface;
Expand Down Expand Up @@ -122,6 +123,7 @@ private function registerQueryType(
}

$queryType = $typeResolver->resolve($class);
assert($queryType instanceof Webonyx\NamedType);
$typeRegistry->register($queryType, $class);
}

Expand All @@ -138,8 +140,9 @@ private function registerMutationType(
$class = MutationType::class;
}

$queryType = $typeResolver->resolve($class);
$typeRegistry->register($queryType, $class);
$mutationType = $typeResolver->resolve($class);
assert($mutationType instanceof Webonyx\NamedType);
$typeRegistry->register($mutationType, $class);
}

private function registerAdditionalTypes(
Expand All @@ -154,7 +157,7 @@ private function registerAdditionalTypes(
}

$type = $typeResolver->resolve($name);

assert($type instanceof Webonyx\NamedType);
$typeRegistry->register($type, ...$aliases);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/Listener/AttributedTypeLoaderListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Andi\GraphQL\Exception\CantResolveGraphQLTypeException;
use Andi\GraphQL\TypeRegistryInterface;
use Andi\GraphQL\TypeResolver\TypeResolverInterface;
use GraphQL\Type\Definition\NamedType;
use ReflectionClass;
use Spiral\Attributes\ReaderInterface;
use Spiral\Tokenizer\Attribute\TargetAttribute;
Expand Down Expand Up @@ -45,6 +46,7 @@ public function listen(ReflectionClass $class): void
$typeName = (string) $type;

if (! $this->typeRegistry->has($typeName)) {
assert($type instanceof NamedType);
$this->typeRegistry->register($type, $class->getName());
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Listener/TypeLoaderListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function listen(ReflectionClass $class): void

try {
$type = $this->typeResolver->resolve($className);
assert($type instanceof Webonyx\NamedType);
$this->typeRegistry->register($type, $className);
} catch (CantResolveGraphQLTypeException $e) {
$this->reporter->report($e);
Expand Down
4 changes: 3 additions & 1 deletion src/Middleware/GraphQLMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
$response = $this->responseFactory->createResponse();
$stream = $this->streamFactory->createStream();

return $this->server->processPsrRequest($request, $response, $stream);
$result = $this->server->processPsrRequest($request, $response, $stream);
assert($result instanceof ResponseInterface);
return $result;
}

return $handler->handle($request);
Expand Down

0 comments on commit ddc2513

Please sign in to comment.