Skip to content

Commit 2377c25

Browse files
committed
fix: clone inherits validate deprecated
1 parent fce271c commit 2377c25

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

graphql.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ func (s *Schema) Clone(resolver any, opts ...SchemaOpt) (*Schema, error) {
110110
disableFieldSelections: s.disableFieldSelections,
111111
disableMemoryPooling: s.disableMemoryPooling,
112112
overlapPairLimit: s.overlapPairLimit,
113+
validateDeprecated: s.validateDeprecated,
113114
}
114115

115116
for _, opt := range opts {

graphql_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5473,6 +5473,29 @@ func TestSchemaCloneWithOptions(t *testing.T) {
54735473
}
54745474
}
54755475

5476+
func TestSchemaCloneInheritsValidateDeprecated(t *testing.T) {
5477+
const sdl = `
5478+
schema { query: Query }
5479+
type Query {
5480+
deprecatedField: String! @deprecated(reason: "Use replacementField")
5481+
}
5482+
`
5483+
baseSchema := graphql.MustParseSchema(sdl, &testValidateDeprecatedResolver{}, graphql.ValidateDeprecated())
5484+
clone := baseSchema.MustClone(&testValidateDeprecatedResolver{})
5485+
5486+
gqltesting.RunTest(t, &gqltesting.Test{
5487+
Schema: clone,
5488+
Query: `{ deprecatedField }`,
5489+
ExpectedErrors: []*gqlerrors.QueryError{
5490+
{
5491+
Message: "The field Query.deprecatedField is deprecated. Use replacementField",
5492+
Locations: []gqlerrors.Location{{Line: 1, Column: 3}},
5493+
Rule: "NoDeprecatedCustomRule",
5494+
},
5495+
},
5496+
})
5497+
}
5498+
54765499
func TestSchemaCloneMultiTenant(t *testing.T) {
54775500
privateSchema := graphql.MustParseSchema(starwars.Schema, &starwars.Resolver{}, graphql.MaxDepth(8))
54785501
publicSchema, err := privateSchema.Clone(&starwars.Resolver{}, graphql.MaxDepth(3))

0 commit comments

Comments
 (0)