Skip to content

Commit d5e2e97

Browse files
committed
Document GraphQL test string conventions
1 parent e726913 commit d5e2e97

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

.claude/CLAUDE.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ Multiple service providers for optional features (auto-discovered via composer.j
7777

7878
Tests use `Tests\Utils\` namespace for test fixtures (Models, Queries, Mutations, etc.).
7979

80+
### GraphQL string style in tests
81+
82+
- Always annotate GraphQL literals with `/** @lang GraphQL */`.
83+
- Default to nowdoc: `<<<'GRAPHQL'`.
84+
- Use heredoc: `<<<GRAPHQL` only if interpolation is required.
85+
- Avoid quoted multiline GraphQL strings.
86+
- Preserve intentional indentation/whitespace in schema and assertion-sensitive tests.
87+
8088
## Code Style
8189

8290
- PHPStan level 8

CONTRIBUTING.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,16 @@ $user = User::create([
128128
]);
129129
```
130130

131+
### GraphQL strings in tests
132+
133+
Use a consistent representation for GraphQL literals in tests:
134+
135+
- Use `/** @lang GraphQL */` before GraphQL string literals.
136+
- Use nowdoc (`<<<'GRAPHQL'`) for static GraphQL content.
137+
- Use heredoc (`<<<GRAPHQL`) only when interpolation is required.
138+
- Prefer nowdoc/heredoc over quoted multiline strings.
139+
- For schema/assertion cases where whitespace matters, keep indentation deliberate and stable.
140+
131141
## Working with proto files
132142

133143
Lighthouse uses [protobuf](https://developers.google.com/protocol-buffers) files for [federated tracing](src/Tracing/FederatedTracing/reports.proto).

0 commit comments

Comments
 (0)