Skip to content

Commit fc931e6

Browse files
authored
Merge pull request #12 from TomHAnderson/hotfix/Error
Force www-data user; add exception handling to mutation
2 parents 3360a0b + d7f18cd commit fc931e6

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

.docker/apache2.conf

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,8 @@ MaxKeepAliveRequests 100
112112
#
113113
KeepAliveTimeout 5
114114

115-
116-
# These need to be set in /etc/apache2/envvars
117-
User ${APACHE_RUN_USER}
118-
Group ${APACHE_RUN_GROUP}
115+
User www-data
116+
Group www-data
119117

120118
#
121119
# HostnameLookups: Log the names of clients or just their IP addresses

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,10 @@ RUN composer install --no-dev
7575
RUN touch /var/www/storage/logs/laravel.log && \
7676
rm /var/www/storage/logs/laravel.log && \
7777
touch /var/www/storage/logs/laravel.log
78-
RUN chgrp -R www-data storage bootstrap/cache database/database.sqlite
79-
RUN chmod -R ug+rwx storage bootstrap/cache database/database.sqlite
78+
RUN chgrp -R www-data storage bootstrap/cache
79+
RUN chmod -R ug+rwx storage bootstrap/cache
80+
RUN chgrp -R www-data database/database.sqlite
81+
RUN chmod -R ug+rwx database/database.sqlite
8082

8183
# Expose port
8284
EXPOSE 8080

app/GraphQL/Mutation/Artist/Create.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
use App\GraphQL\Field;
1010
use Doctrine\Laminas\Hydrator\DoctrineObject;
1111
use Doctrine\ORM\EntityManager;
12+
use GraphQL\Error\Error;
1213
use GraphQL\Type\Definition\ResolveInfo;
14+
use Throwable;
1315

1416
class Create implements Field
1517
{
@@ -33,7 +35,12 @@ public static function getDefinition(
3335

3436
$driver->get(DoctrineObject::class)->hydrate($args['values'], $artist);
3537
$driver->get(EntityManager::class)->persist($artist);
36-
$driver->get(EntityManager::class)->flush();
38+
39+
try {
40+
$driver->get(EntityManager::class)->flush();
41+
} catch (Throwable $e) {
42+
throw new Error($e->getMessage());
43+
}
3744

3845
return $artist;
3946
},

database/database.sqlite

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)