-
Notifications
You must be signed in to change notification settings - Fork 46
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
fix(compiler): fix validation for fragment spread of interface without implementers #896
Merged
goto-bus-stop
merged 3 commits into
main
from
renee/validate-query-with-no-interface-implementers
Aug 26, 2024
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
5d804c9
fix(compiler): add failing test for spread of empty interface
goto-bus-stop a85df6f
fix(compiler): always accept spreading ...Ty when parent type is Ty
goto-bus-stop 77a0b3d
Merge branch 'main' into renee/validate-query-with-no-interface-imple…
goto-bus-stop File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
crates/apollo-compiler/test_data/ok/0116_interface_without_implementations.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
type Query { | ||
intf: Intf | ||
} | ||
interface Intf { | ||
field: Int | ||
} | ||
|
||
query SelectDirectly { | ||
intf { field } | ||
} | ||
|
||
query UsingInlineFragment { | ||
intf { | ||
... on Intf { field } | ||
} | ||
} |
232 changes: 232 additions & 0 deletions
232
crates/apollo-compiler/test_data/ok/0116_interface_without_implementations.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,232 @@ | ||
Schema { | ||
sources: { | ||
1: SourceFile { | ||
path: "built_in.graphql", | ||
source_text: include_str!("built_in.graphql"), | ||
}, | ||
45: SourceFile { | ||
path: "0116_interface_without_implementations.graphql", | ||
source_text: "type Query {\n intf: Intf\n}\ninterface Intf {\n field: Int\n}\n\nquery SelectDirectly {\n intf { field }\n}\n\nquery UsingInlineFragment {\n intf {\n ... on Intf { field }\n }\n}\n", | ||
}, | ||
}, | ||
schema_definition: SchemaDefinition { | ||
description: None, | ||
directives: [], | ||
query: Some( | ||
ComponentName { | ||
origin: Definition, | ||
name: "Query", | ||
}, | ||
), | ||
mutation: None, | ||
subscription: None, | ||
}, | ||
directive_definitions: { | ||
"skip": built_in_directive!("skip"), | ||
"include": built_in_directive!("include"), | ||
"deprecated": built_in_directive!("deprecated"), | ||
"specifiedBy": built_in_directive!("specifiedBy"), | ||
}, | ||
types: { | ||
"__Schema": built_in_type!("__Schema"), | ||
"__Type": built_in_type!("__Type"), | ||
"__TypeKind": built_in_type!("__TypeKind"), | ||
"__Field": built_in_type!("__Field"), | ||
"__InputValue": built_in_type!("__InputValue"), | ||
"__EnumValue": built_in_type!("__EnumValue"), | ||
"__Directive": built_in_type!("__Directive"), | ||
"__DirectiveLocation": built_in_type!("__DirectiveLocation"), | ||
"Int": built_in_type!("Int"), | ||
"Float": built_in_type!("Float"), | ||
"String": built_in_type!("String"), | ||
"Boolean": built_in_type!("Boolean"), | ||
"ID": built_in_type!("ID"), | ||
"Query": Object( | ||
0..27 @45 ObjectType { | ||
description: None, | ||
name: "Query", | ||
implements_interfaces: {}, | ||
directives: [], | ||
fields: { | ||
"intf": Component { | ||
origin: Definition, | ||
node: 15..25 @45 FieldDefinition { | ||
description: None, | ||
name: "intf", | ||
arguments: [], | ||
ty: Named( | ||
"Intf", | ||
), | ||
directives: [], | ||
}, | ||
}, | ||
}, | ||
}, | ||
), | ||
"Intf": Interface( | ||
28..59 @45 InterfaceType { | ||
description: None, | ||
name: "Intf", | ||
implements_interfaces: {}, | ||
directives: [], | ||
fields: { | ||
"field": Component { | ||
origin: Definition, | ||
node: 47..57 @45 FieldDefinition { | ||
description: None, | ||
name: "field", | ||
arguments: [], | ||
ty: Named( | ||
"Int", | ||
), | ||
directives: [], | ||
}, | ||
}, | ||
}, | ||
}, | ||
), | ||
}, | ||
} | ||
ExecutableDocument { | ||
sources: { | ||
1: SourceFile { | ||
path: "built_in.graphql", | ||
source_text: include_str!("built_in.graphql"), | ||
}, | ||
45: SourceFile { | ||
path: "0116_interface_without_implementations.graphql", | ||
source_text: "type Query {\n intf: Intf\n}\ninterface Intf {\n field: Int\n}\n\nquery SelectDirectly {\n intf { field }\n}\n\nquery UsingInlineFragment {\n intf {\n ... on Intf { field }\n }\n}\n", | ||
}, | ||
}, | ||
operations: OperationMap { | ||
anonymous: None, | ||
named: { | ||
"SelectDirectly": 61..102 @45 Operation { | ||
operation_type: Query, | ||
name: Some( | ||
"SelectDirectly", | ||
), | ||
variables: [], | ||
directives: [], | ||
selection_set: SelectionSet { | ||
ty: "Query", | ||
selections: [ | ||
Field( | ||
86..100 @45 Field { | ||
definition: 15..25 @45 FieldDefinition { | ||
description: None, | ||
name: "intf", | ||
arguments: [], | ||
ty: Named( | ||
"Intf", | ||
), | ||
directives: [], | ||
}, | ||
alias: None, | ||
name: "intf", | ||
arguments: [], | ||
directives: [], | ||
selection_set: SelectionSet { | ||
ty: "Intf", | ||
selections: [ | ||
Field( | ||
93..98 @45 Field { | ||
definition: 47..57 @45 FieldDefinition { | ||
description: None, | ||
name: "field", | ||
arguments: [], | ||
ty: Named( | ||
"Int", | ||
), | ||
directives: [], | ||
}, | ||
alias: None, | ||
name: "field", | ||
arguments: [], | ||
directives: [], | ||
selection_set: SelectionSet { | ||
ty: "Int", | ||
selections: [], | ||
}, | ||
}, | ||
), | ||
], | ||
}, | ||
}, | ||
), | ||
], | ||
}, | ||
}, | ||
"UsingInlineFragment": 104..172 @45 Operation { | ||
operation_type: Query, | ||
name: Some( | ||
"UsingInlineFragment", | ||
), | ||
variables: [], | ||
directives: [], | ||
selection_set: SelectionSet { | ||
ty: "Query", | ||
selections: [ | ||
Field( | ||
134..170 @45 Field { | ||
definition: 15..25 @45 FieldDefinition { | ||
description: None, | ||
name: "intf", | ||
arguments: [], | ||
ty: Named( | ||
"Intf", | ||
), | ||
directives: [], | ||
}, | ||
alias: None, | ||
name: "intf", | ||
arguments: [], | ||
directives: [], | ||
selection_set: SelectionSet { | ||
ty: "Intf", | ||
selections: [ | ||
InlineFragment( | ||
145..166 @45 InlineFragment { | ||
type_condition: Some( | ||
"Intf", | ||
), | ||
directives: [], | ||
selection_set: SelectionSet { | ||
ty: "Intf", | ||
selections: [ | ||
Field( | ||
159..164 @45 Field { | ||
definition: 47..57 @45 FieldDefinition { | ||
description: None, | ||
name: "field", | ||
arguments: [], | ||
ty: Named( | ||
"Int", | ||
), | ||
directives: [], | ||
}, | ||
alias: None, | ||
name: "field", | ||
arguments: [], | ||
directives: [], | ||
selection_set: SelectionSet { | ||
ty: "Int", | ||
selections: [], | ||
}, | ||
}, | ||
), | ||
], | ||
}, | ||
}, | ||
), | ||
], | ||
}, | ||
}, | ||
), | ||
], | ||
}, | ||
}, | ||
}, | ||
}, | ||
fragments: {}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...es/apollo-compiler/test_data/serializer/ok/0116_interface_without_implementations.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
type Query { | ||
intf: Intf | ||
} | ||
|
||
interface Intf { | ||
field: Int | ||
} | ||
|
||
query SelectDirectly { | ||
intf { | ||
field | ||
} | ||
} | ||
|
||
query UsingInlineFragment { | ||
intf { | ||
... on Intf { | ||
field | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated change, just fixing the schema so it doesn't rely on having an interface with 0 implementers