FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Check in field visibility transformer test - union member error now fixed by dondonz · Pull Request #4275 · graphql-java/graphql-java · GitHub

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .groovy  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or 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
Expand Up @@ -2010,4 +2010,73 @@ class FieldVisibilitySchemaTransformationTest extends Specification {
assertSchemaIsValid(restrictedSchema)
}

def "type is not deleted if remains a union member after its only private field path is removed"() {
given:
GraphQLSchema schema = TestUtil.schema("""

directive @private on FIELD_DEFINITION

type Query {
hello: String
createPizzaTopping(name: String!): PizzaToppingCreationPayload @private
toBeRemoved: PizzaToBeRemoved @private
}

union PizzaPolicy =
| PizzaTopping
| PizzaCrust
| PizzaDiscount
| PizzaAllergen

interface Payload {
success: Boolean!
}

type PizzaToppingCreationPayload implements Payload {
topping: PizzaTopping
success: Boolean!
}

type PizzaTopping {
id: ID
name: String
}

type PizzaCrust {
id: ID
name: String
}

type PizzaDiscount {
id: ID
percentage: Float
}

type PizzaAllergen {
id: ID
allergen: String
}

type PizzaToBeRemoved {
id: ID
}
""")

when:
GraphQLSchema restrictedSchema = visibilitySchemaTransformation.apply(schema)

then: "the private field paths are removed"
(restrictedSchema.getType("Query") as GraphQLObjectType).getFieldDefinition("createPizzaTopping") == null
restrictedSchema.getType("PizzaToppingCreationPayload") == null

and: "PizzaTopping is still present because it is reachable as a union member of the public PizzaPolicy"
restrictedSchema.getType("PizzaTopping") != null

and: "Types with no reference at all (not a union member) is correctly removed"
restrictedSchema.getType("PizzaToBeRemoved") == null

and: "the resulting schema is valid - previously this would produce an invalid schema"
assertSchemaIsValid(restrictedSchema)
}

}
Loading

Back | FazBrowse Home | New Git URL