Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
16 changes: 11 additions & 5 deletions crates/apollo-compiler/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,20 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## Features

- **Adds `ignore_builtin_redefinitions` option to `SchemaBuilder` to allow SDL to contain built-in
scalar definitions - [dariuszkuc], [pull/990]**
- **Adds `ignore_builtin_redefinitions` option to `SchemaBuilder` to allow SDL to contain built-in type
definitions - [dariuszkuc], [pull/990] and [pull/994]**

## Fixes

- **Fix handling of orphan root type extensions - [dariuszkuc], [pull/993]**
- **Fix possible stack overflow in validation of directive definition arguments with nested types - [dariuszkuc], [pull/987]**
- **Fix `iter_origin()` to be a pub method- [duckki], [pull/989]**
- **Fix handling of orphan root type extensions - [dariuszkuc], [pull/993](#993)**
- **Fix possible stack overflow in validation of directive definition arguments with nested types - [dariuszkuc], [pull/987](#987)**
- **Fix `iter_origin()` to be a pub method- [duckki], [pull/989](#989)**

[pull/994]: https://github.com/apollographql/apollo-rs/pull/994
[pull/993]: https://github.com/apollographql/apollo-rs/pull/993
[pull/990]: https://github.com/apollographql/apollo-rs/pull/990
[pull/989]: https://github.com/apollographql/apollo-rs/pull/989
[pull/987]: https://github.com/apollographql/apollo-rs/pull/987

# [1.29.0](https://crates.io/crates/apollo-compiler/1.29.0) - 2025-08-08

Expand Down
16 changes: 8 additions & 8 deletions crates/apollo-compiler/src/schema/from_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ impl SchemaBuilder {
}
Entry::Occupied(entry) => {
let previous = entry.get();
if self.ignore_builtin_redefinitions && previous.is_built_in() {
continue;
}

if $is_scalar && previous.is_built_in() {
if self.ignore_builtin_redefinitions {
continue;
} else {
self.errors.push(
$def.location(),
BuildError::BuiltInScalarTypeRedefinition,
)
}
self.errors.push(
$def.location(),
BuildError::BuiltInScalarTypeRedefinition,
)
} else {
self.errors.push(
$def.name.location(),
Expand Down
47 changes: 46 additions & 1 deletion crates/apollo-compiler/tests/validation/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2020,7 +2020,7 @@ mod variable_default_values {
}

#[test]
fn handles_built_in_type_redefinition() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This types.rs file was for ValuesOfCorrectType Rule tests, so I moved these builtin_type_redefinition tests into their own file.

fn handles_built_in_scalar_redefinition() {
let schema = r#"
scalar String

Expand Down Expand Up @@ -2049,3 +2049,48 @@ type Query {
.build()
.expect("schema parsed successfully");
}

#[test]
fn handles_built_in_type_redefinition() {
let schema = r#"
type __Directive {
name: String!
description: String!
isRepeatable: String!
args: __InputValue
locations: String!
}

type Query {
foo: String
}
"#;

let errors = Schema::parse_and_validate(schema, "schema.graphql")
.expect_err("invalid schema")
.errors;
let expected = expect![[r#"
Error: the type `__Directive` is defined multiple times in the schema
╭─[ built_in.graphql:87:6 ]
87 │ type __Directive {
│ ─────┬─────
│ ╰─────── previous definition of `__Directive` here
├─[ schema.graphql:2:6 ]
2 │ type __Directive {
│ ─────┬─────
│ ╰─────── `__Directive` redefined here
│ Help: remove or rename one of the definitions, or use `extend`
────╯
"#]];
expected.assert_eq(&errors.to_string());

let builder = SchemaBuilder::new().ignore_builtin_redefinitions();
let _ = builder
.parse(schema, "schema.graphql")
.build()
.expect("schema parsed successfully");
}