Skip to content
Merged
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
1 change: 1 addition & 0 deletions graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ func (s *Schema) Clone(resolver any, opts ...SchemaOpt) (*Schema, error) {
disableFieldSelections: s.disableFieldSelections,
disableMemoryPooling: s.disableMemoryPooling,
overlapPairLimit: s.overlapPairLimit,
validateDeprecated: s.validateDeprecated,
}

for _, opt := range opts {
Expand Down
23 changes: 23 additions & 0 deletions graphql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5473,6 +5473,29 @@ func TestSchemaCloneWithOptions(t *testing.T) {
}
}

func TestSchemaCloneInheritsValidateDeprecated(t *testing.T) {
const sdl = `
schema { query: Query }
type Query {
deprecatedField: String! @deprecated(reason: "Use replacementField")
}
`
baseSchema := graphql.MustParseSchema(sdl, &testValidateDeprecatedResolver{}, graphql.ValidateDeprecated())
clone := baseSchema.MustClone(&testValidateDeprecatedResolver{})

gqltesting.RunTest(t, &gqltesting.Test{
Schema: clone,
Query: `{ deprecatedField }`,
ExpectedErrors: []*gqlerrors.QueryError{
{
Message: "The field Query.deprecatedField is deprecated. Use replacementField",
Locations: []gqlerrors.Location{{Line: 1, Column: 3}},
Rule: "NoDeprecatedCustomRule",
},
},
})
}

func TestSchemaCloneMultiTenant(t *testing.T) {
privateSchema := graphql.MustParseSchema(starwars.Schema, &starwars.Resolver{}, graphql.MaxDepth(8))
publicSchema, err := privateSchema.Clone(&starwars.Resolver{}, graphql.MaxDepth(3))
Expand Down