Skip to content

Commit 365f9f0

Browse files
spawniaenisdenjogithub-actions[bot]
authored
docs(audits/server): add lighthouse implementation (#60)
Co-authored-by: enisdenjo <badurinadenis@gmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent d72e344 commit 365f9f0

File tree

7 files changed

+333
-0
lines changed

7 files changed

+333
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,7 @@ Their compliance with the [GraphQL over HTTP spec](https://graphql.github.io/gra
788788
| [graphql-helix](https://www.graphql-helix.com) | [✅ Compliant](/implementations/graphql-helix/README.md) |
789789
| [graphql-yoga](https://www.the-guild.dev/graphql/yoga-server) | [✅ Compliant](/implementations/graphql-yoga/README.md) |
790790
| [hotchocolate](https://chillicream.com/docs/hotchocolate) | [✅ Compliant](/implementations/hotchocolate/README.md) |
791+
| [lighthouse](https://lighthouse-php.com) | [✅ Compliant](/implementations/lighthouse/README.md) |
791792
| [pioneer](https://pioneer.dexclaimation.com) | [✅ Compliant](/implementations/pioneer/README.md) |
792793
| [postgraphile](https://www.graphile.org/postgraphile) | [✅ Compliant](/implementations/postgraphile/README.md) |
793794
<!-- prettier-ignore-end -->

implementations/lighthouse/Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM php:8.1-cli
2+
3+
WORKDIR /app
4+
5+
COPY --from=composer /usr/bin/composer /usr/bin/composer
6+
7+
RUN apt-get update && \
8+
apt-get install --yes \
9+
git \
10+
libzip-dev \
11+
zip \
12+
&& docker-php-ext-install \
13+
zip \
14+
&& rm -rf /var/lib/apt/lists/*
15+
RUN composer create-project laravel/laravel /app
16+
RUN composer require nuwave/lighthouse
17+
RUN php artisan vendor:publish --tag=lighthouse-schema

implementations/lighthouse/README.md

Lines changed: 282 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
1+
<i>* This report was auto-generated by graphql-http</i>
2+
3+
<h1>GraphQL over HTTP audit report</h1>
4+
5+
<ul>
6+
<li><b>37</b> audits in total</li>
7+
<li><span style="font-family: monospace">✅</span> <b>30</b> pass</li>
8+
<li><span style="font-family: monospace">⚠️</span> <b>7</b> warnings (optional)</li>
9+
</ul>
10+
11+
<h2>Passing</h2>
12+
<ol>
13+
<li><code>4655</code> MUST accept application/json and match the content-type</li>
14+
<li><code>47DE</code> SHOULD accept */* and use application/json for the content-type</li>
15+
<li><code>80D8</code> SHOULD assume application/json content-type when accept is missing</li>
16+
<li><code>82A3</code> MUST use utf-8 encoding when responding</li>
17+
<li><code>BF61</code> MUST accept utf-8 encoded request</li>
18+
<li><code>78D5</code> MUST assume utf-8 in request if encoding is unspecified</li>
19+
<li><code>2C94</code> MUST accept POST requests</li>
20+
<li><code>5A70</code> MAY accept application/x-www-form-urlencoded formatted GET requests</li>
21+
<li><code>03D4</code> MUST accept application/json POST requests</li>
22+
<li><code>34A2</code> SHOULD allow string {query} parameter when accepting application/graphql-response+json</li>
23+
<li><code>13EE</code> MUST allow string {query} parameter when accepting application/json</li>
24+
<li><code>8161</code> SHOULD allow string {operationName} parameter when accepting application/graphql-response+json</li>
25+
<li><code>B8B3</code> MUST allow string {operationName} parameter when accepting application/json</li>
26+
<li><code>94B0</code> SHOULD allow null {variables} parameter when accepting application/graphql-response+json</li>
27+
<li><code>0220</code> MUST allow null {variables} parameter when accepting application/json</li>
28+
<li><code>94B1</code> SHOULD allow null {operationName} parameter when accepting application/graphql-response+json</li>
29+
<li><code>0221</code> MUST allow null {operationName} parameter when accepting application/json</li>
30+
<li><code>94B2</code> SHOULD allow null {extensions} parameter when accepting application/graphql-response+json</li>
31+
<li><code>0222</code> MUST allow null {extensions} parameter when accepting application/json</li>
32+
<li><code>2EA1</code> SHOULD allow map {variables} parameter when accepting application/graphql-response+json</li>
33+
<li><code>28B9</code> MUST allow map {variables} parameter when accepting application/json</li>
34+
<li><code>D6D5</code> MAY allow URL-encoded JSON string {variables} parameter in GETs when accepting application/graphql-response+json</li>
35+
<li><code>6A70</code> MAY allow URL-encoded JSON string {variables} parameter in GETs when accepting application/json</li>
36+
<li><code>428F</code> SHOULD allow map {extensions} parameter when accepting application/graphql-response+json</li>
37+
<li><code>1B7A</code> MUST allow map {extensions} parameter when accepting application/json</li>
38+
<li><code>572B</code> SHOULD use 200 status code on document parsing failure when accepting application/json</li>
39+
<li><code>FDE2</code> SHOULD use 200 status code on document validation failure when accepting application/json</li>
40+
<li><code>7B9B</code> SHOULD use a status code of 200 on variable coercion failure when accepting application/json</li>
41+
<li><code>D586</code> SHOULD not contain the data entry on document parsing failure when accepting application/graphql-response+json</li>
42+
<li><code>5E5B</code> SHOULD not contain the data entry on document validation failure when accepting application/graphql-response+json</li>
43+
</ol>
44+
45+
<h2>Warnings</h2>
46+
The server <i>SHOULD</i> support these, but is not required.
47+
<ol>
48+
<li><code>22EB</code> SHOULD accept application/graphql-response+json and match the content-type
49+
<details>
50+
<summary>Response header content-type does not contain application/graphql-response+json</summary>
51+
<pre><code class="lang-json">{
52+
"statusText": "OK",
53+
"status": 200,
54+
"headers": {
55+
"x-powered-by": "PHP/8.1.17",
56+
"host": "localhost:4000",
57+
"date": "<timestamp>",
58+
"content-type": "application/json",
59+
"connection": "close",
60+
"cache-control": "no-cache, private"
61+
},
62+
"body": {
63+
"data": {
64+
"__typename": "Query"
65+
}
66+
}
67+
}
68+
</code></pre>
69+
</details>
70+
</li>
71+
<li><code>9C48</code> MAY NOT allow executing mutations on GET requests
72+
<details>
73+
<summary>Response status is not between 400 and 499</summary>
74+
<pre><code class="lang-json">{
75+
"statusText": "OK",
76+
"status": 200,
77+
"headers": {
78+
"x-powered-by": "PHP/8.1.17",
79+
"host": "localhost:4000",
80+
"date": "<timestamp>",
81+
"content-type": "application/json",
82+
"connection": "close",
83+
"cache-control": "no-cache, private"
84+
},
85+
"body": {
86+
"errors": [
87+
{
88+
"message": "Schema is not configured for mutations.",
89+
"locations": [
90+
{
91+
"line": 1,
92+
"column": 1
93+
}
94+
],
95+
"extensions": {
96+
"line": 350,
97+
"file": "/app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php"
98+
}
99+
}
100+
]
101+
}
102+
}
103+
</code></pre>
104+
</details>
105+
</li>
106+
<li><code>865D</code> SHOULD use 4xx or 5xx status codes on document parsing failure when accepting application/graphql-response+json
107+
<details>
108+
<summary>Response status is not between 400 and 599</summary>
109+
<pre><code class="lang-json">{
110+
"statusText": "OK",
111+
"status": 200,
112+
"headers": {
113+
"x-powered-by": "PHP/8.1.17",
114+
"host": "localhost:4000",
115+
"date": "<timestamp>",
116+
"content-type": "application/json",
117+
"connection": "close",
118+
"cache-control": "no-cache, private"
119+
},
120+
"body": {
121+
"errors": [
122+
{
123+
"message": "Syntax Error: Expected Name, found <EOF>",
124+
"locations": [
125+
{
126+
"line": 1,
127+
"column": 2
128+
}
129+
],
130+
"extensions": {
131+
"line": 383,
132+
"file": "/app/vendor/webonyx/graphql-php/src/Language/Parser.php"
133+
}
134+
}
135+
]
136+
}
137+
}
138+
</code></pre>
139+
</details>
140+
</li>
141+
<li><code>556A</code> SHOULD use 400 status code on document parsing failure when accepting application/graphql-response+json
142+
<details>
143+
<summary>Response status code is not 400</summary>
144+
<pre><code class="lang-json">{
145+
"statusText": "OK",
146+
"status": 200,
147+
"headers": {
148+
"x-powered-by": "PHP/8.1.17",
149+
"host": "localhost:4000",
150+
"date": "<timestamp>",
151+
"content-type": "application/json",
152+
"connection": "close",
153+
"cache-control": "no-cache, private"
154+
},
155+
"body": {
156+
"errors": [
157+
{
158+
"message": "Syntax Error: Expected Name, found <EOF>",
159+
"locations": [
160+
{
161+
"line": 1,
162+
"column": 2
163+
}
164+
],
165+
"extensions": {
166+
"line": 383,
167+
"file": "/app/vendor/webonyx/graphql-php/src/Language/Parser.php"
168+
}
169+
}
170+
]
171+
}
172+
}
173+
</code></pre>
174+
</details>
175+
</li>
176+
<li><code>51FE</code> SHOULD use 4xx or 5xx status codes on document validation failure when accepting application/graphql-response+json
177+
<details>
178+
<summary>Response status is not between 400 and 599</summary>
179+
<pre><code class="lang-json">{
180+
"statusText": "OK",
181+
"status": 200,
182+
"headers": {
183+
"x-powered-by": "PHP/8.1.17",
184+
"host": "localhost:4000",
185+
"date": "<timestamp>",
186+
"content-type": "application/json",
187+
"connection": "close",
188+
"cache-control": "no-cache, private"
189+
},
190+
"body": {
191+
"errors": [
192+
{
193+
"message": "Syntax Error: Expected Name, found Int \"8\"",
194+
"locations": [
195+
{
196+
"line": 1,
197+
"column": 3
198+
}
199+
],
200+
"extensions": {
201+
"line": 383,
202+
"file": "/app/vendor/webonyx/graphql-php/src/Language/Parser.php"
203+
}
204+
}
205+
]
206+
}
207+
}
208+
</code></pre>
209+
</details>
210+
</li>
211+
<li><code>74FF</code> SHOULD use 400 status code on document validation failure when accepting application/graphql-response+json
212+
<details>
213+
<summary>Response status code is not 400</summary>
214+
<pre><code class="lang-json">{
215+
"statusText": "OK",
216+
"status": 200,
217+
"headers": {
218+
"x-powered-by": "PHP/8.1.17",
219+
"host": "localhost:4000",
220+
"date": "<timestamp>",
221+
"content-type": "application/json",
222+
"connection": "close",
223+
"cache-control": "no-cache, private"
224+
},
225+
"body": {
226+
"errors": [
227+
{
228+
"message": "Syntax Error: Expected Name, found Int \"8\"",
229+
"locations": [
230+
{
231+
"line": 1,
232+
"column": 3
233+
}
234+
],
235+
"extensions": {
236+
"line": 383,
237+
"file": "/app/vendor/webonyx/graphql-php/src/Language/Parser.php"
238+
}
239+
}
240+
]
241+
}
242+
}
243+
</code></pre>
244+
</details>
245+
</li>
246+
<li><code>86EE</code> SHOULD use a status code of 400 on variable coercion failure when accepting application/graphql-response+json
247+
<details>
248+
<summary>Response status code is not 400</summary>
249+
<pre><code class="lang-json">{
250+
"statusText": "OK",
251+
"status": 200,
252+
"headers": {
253+
"x-powered-by": "PHP/8.1.17",
254+
"host": "localhost:4000",
255+
"date": "<timestamp>",
256+
"content-type": "application/json",
257+
"connection": "close",
258+
"cache-control": "no-cache, private"
259+
},
260+
"body": {
261+
"errors": [
262+
{
263+
"message": "Variable \"$id\" is never used in operation \"CoerceFailure\".",
264+
"locations": [
265+
{
266+
"line": 1,
267+
"column": 21
268+
}
269+
],
270+
"extensions": {
271+
"line": 41,
272+
"file": "/app/vendor/webonyx/graphql-php/src/Validator/Rules/NoUnusedVariables.php"
273+
}
274+
}
275+
]
276+
}
277+
}
278+
</code></pre>
279+
</details>
280+
</li>
281+
</ol>
282+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
services:
2+
lighthouse:
3+
build: .
4+
environment:
5+
- PORT=${PORT}
6+
ports:
7+
- ${PORT}:${PORT}
8+
entrypoint: 'php artisan serve --host=0.0.0.0 --port=${PORT}'
9+
healthcheck:
10+
test: curl -f http://localhost:$$PORT/graphql?query=%7B__typename%7D || exit 1
11+
interval: 3s
12+
timeout: 1s
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"private": true,
3+
"name": "lighthouse",
4+
"url": "https://lighthouse-php.com",
5+
"packageManager": "yarn@3.2.3",
6+
"scripts": {
7+
"start": "docker compose up"
8+
}
9+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"total": 37,
3+
"ok": 30,
4+
"warn": 7,
5+
"error": 0
6+
}

yarn.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9311,6 +9311,12 @@ __metadata:
93119311
languageName: node
93129312
linkType: hard
93139313

9314+
"lighthouse@workspace:implementations/lighthouse":
9315+
version: 0.0.0-use.local
9316+
resolution: "lighthouse@workspace:implementations/lighthouse"
9317+
languageName: unknown
9318+
linkType: soft
9319+
93149320
"lines-and-columns@npm:^1.1.6":
93159321
version: 1.2.4
93169322
resolution: "lines-and-columns@npm:1.2.4"

0 commit comments

Comments
 (0)