Skip to content

Fix known type names validation for fragments with experimental variables #1707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ You can find and compare releases at the [GitHub release page](https://github.co

## Unreleased

### Fixed

- KnownTypeNames validation for fragments with variables (experimentalFragmentVariables option)

## v15.20.0

### Added
Expand Down
2 changes: 1 addition & 1 deletion src/Language/AST/FragmentDefinitionNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace GraphQL\Language\AST;

class FragmentDefinitionNode extends Node implements ExecutableDefinitionNode, HasSelectionSet
class FragmentDefinitionNode extends Node implements ExecutableDefinitionNode, HasSelectionSet, TypeSystemDefinitionNode
{
public string $kind = NodeKind::FRAGMENT_DEFINITION;

Expand Down
24 changes: 24 additions & 0 deletions tests/Validator/KnownTypeNamesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,30 @@ public function testKnownTypeNamesAreValid(): void
);
}

/** @see it('known type names are valid') */
public function testKnownTypeWithExperimentalFragmentVariablesAreValid(): void
{
$this->expectPassesRule(
new KnownTypeNames(),
'
query Foo(
$var: String
$required: [Int!]!
$introspectionType: __EnumValue
) {
user(id: 4) {
pets { ... on Dog { isAtLocationField(x: 0, y: 0) } }
}
}

fragment isAtLocationField($x: Int = 0, $y: Int = 0) on Dog {
isAtLocation(x: $x, y: $y)
}
',
['experimentalFragmentVariables' => true]
);
}

/** @see it('unknown type names are invalid') */
public function testUnknownTypeNamesAreInvalid(): void
{
Expand Down