Skip to content

DataFetchingFieldSelectionSet updates in 16.1 can't handle recursive schema properly and causing slowness #2185

Closed

Description

@ntf

Describe the bug
We are upgrading our library dependency from 15.0 to 16.1 recently and found that DataFetchingFieldSelectionSet updated at #2079 has a regression in performance making our HTTP request 10+ times longer.

We use Java Flight Recorder to narrow down the root cause and found that it is because the HashMap.resize() in NormalizedQueryTreeFactory.createNormalizedQueryImpl.

image

Below screenshots show that the normalizedFieldToMergedField has 1.29 M entries and other local variables here also extremely large in size.
image

image

To Reproduce
Please provide a code example or even better a test to reproduce the bug.

Activity

  1. changed the title [-]DataFetchingFieldSelectionSet updates in 16.0 can't handle recursive schema properly and causing slowness[/-] [+]DataFetchingFieldSelectionSet updates in 16.1 can't handle recursive schema properly and causing slowness[/+] on Feb 4, 2021
  2. andimarek commented on Feb 4, 2021

    @andimarek
    Member

    @ntf thanks for reporting.

    Please make sure you are using 16.2: we fixed a cache in 16.2 regarding NormalizedTree.

    If this doesn't fix it: please provide the query + schema you are using so that we can reproduce/benchmark it.

    If you are not feeling comfortable to post the query + schema have a look at the Anonymizer class we recently added: https://github.com/graphql-java/graphql-java/blob/master/src/main/java/graphql/util/Anonymizer.java
    and also the corresponding test class
    https://github.com/graphql-java/graphql-java/blob/master/src/test/groovy/graphql/util/AnonymizerTest.groovy

  3. ntf commented on Feb 5, 2021

    @ntf
    Author

    16.2 took less time to compute 70% vs 63% .

    image

    This time I notice that the selectionSet is being computed lazily. Remove usage of selection set makes performance back to normal.

    About the Anonymize schema and query, the transformed schema has many validation errors (right) while the original one (left) has no validation error. I will take a look why but it seems that Schema Transformer doesn't handle certain edge cases.
    image

  4. andimarek commented on Feb 5, 2021

    @andimarek
    Member

    @ntf in general we are aware that selectionSet is more compute intense now. That is the price we paid to be able to handle general lookups (including aliases and interfaces/unions).

    The Anonymizer is a quite new (advanced) tool. It would be great to make it work with your schema. If you would be comfortable to share it in private you can reach me at http://twitter.com/andimarek

  5. ntf commented on Feb 5, 2021

    @ntf
    Author

    I use a debugger to print the transformed schema with the SchemaPrinter. Hope this helps.

    new SchemaPrinter().print(graphQLSchema)
    schema {
      query: Object27
      mutation: Object23
    }
    
    "Directs the executor to include this field or fragment only when the `if` argument is true"
    directive @include(
        "Included when true."
        if: Boolean!
      ) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
    
    "Directs the executor to skip this field or fragment when the `if`'argument is true."
    directive @skip(
        "Skipped when true."
        if: Boolean!
      ) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
    
    directive @deprecated(reason: String) on FIELD_DEFINITION | ENUM_VALUE
    
    "Exposes a URL that specifies the behaviour of this scalar."
    directive @specifiedBy(
        "The URL that specifies the behaviour of this scalar."
        url: String!
      ) on SCALAR
    
    interface Interface1 implements Interface2 & Interface3 {
      field1: ID!
      field14: String
      field15: String
      field16: String
      field17: String!
      field18: Scalar1
      field19(argument6: [Enum2] = [EnumValue14], argument7: Int, argument8: String): Object5
      field2: String!
      field24(argument10: [Enum2] = [EnumValue14], argument11: Int, argument12: String, argument9: Float = 1.0): Object5
      field3: Interface2
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    interface Interface2 {
      field1: ID!
      field2: String!
      field3: Interface2
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    interface Interface3 {
      field13: ID!
    }
    
    interface Interface4 implements Interface2 & Interface3 {
      field1: ID!
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    interface Interface5 implements Interface2 & Interface3 {
      field1: ID!
      field2: String!
      field29: String
      field3: Interface2
      field30: String
      field31: String
      field32: String
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    interface Interface6 {
      field38: Boolean!
      field39: String
    }
    
    interface Interface7 {
      field45: ID!
      field46: String!
      field47: Int
      field48: String!
    }
    
    type Object1 implements Interface1 & Interface2 & Interface3 & Interface4 {
      field1: ID!
      field14: String
      field15: String
      field16: String
      field17: String!
      field18: Scalar1
      field19(argument6: [Enum2] = [EnumValue14], argument7: Int, argument8: String): Object5
      field2: String!
      field24(argument10: [Enum2] = [EnumValue14], argument11: Int, argument12: String, argument9: Float = 1.0): Object5
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    type Object10 implements Interface6 {
      field38: Boolean!
      field39: String
      field40: Object6
    }
    
    type Object11 implements Interface2 & Interface3 & Interface4 {
      field1: ID!
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field41: Interface1
    }
    
    type Object12 implements Interface2 & Interface3 & Interface4 {
      field1: ID!
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field42: String!
    }
    
    type Object13 implements Interface2 & Interface3 & Interface4 {
      field1: ID!
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    type Object14 implements Interface2 & Interface3 & Interface5 {
      field1: ID!
      field2: String!
      field29: String
      field3: Interface2
      field30: String
      field31: String
      field32: String
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    type Object15 implements Interface2 & Interface3 & Interface5 {
      field1: ID!
      field2: String!
      field29: String
      field3: Interface2
      field30: String
      field31: String
      field32: String
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    type Object16 implements Interface6 {
      field38: Boolean!
      field39: String
    }
    
    type Object17 {
      field43: [String!]
      field44: String!
    }
    
    type Object18 implements Interface2 & Interface3 & Interface4 & Interface7 {
      field1: ID!
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field48: String!
    }
    
    type Object19 implements Interface2 & Interface3 & Interface4 & Interface7 {
      field1: ID!
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field48: String!
    }
    
    type Object2 {
      field5: [Object3]
      field8: Object4
    }
    
    type Object20 implements Interface2 & Interface3 & Interface4 & Interface7 {
      field1: ID!
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field48: String!
    }
    
    type Object21 implements Interface2 & Interface3 & Interface4 & Interface7 {
      field1: ID!
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field48: String!
    }
    
    type Object22 implements Interface2 & Interface3 {
      field13: ID!
      field2: String!
      field3: Interface2
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    type Object23 {
      field49(argument13: InputObject3): Object24!
      field51(argument14: InputObject4): Object24!
      field52(argument15: InputObject3): Object24!
      field53(argument16: InputObject4): Object24!
      field54(argument17: InputObject5): Object24!
      field55(argument18: InputObject6): Object24!
      field56(argument19: InputObject7): Object24!
      field57(argument20: InputObject9): Object24!
      field58(argument21: InputObject10): Object25!
      field60(argument22: InputObject11): Object26!
      field62(argument23: InputObject12): Object24!
    }
    
    type Object24 implements Interface6 {
      field38: Boolean!
      field39: String
      field50: Object8
    }
    
    type Object25 implements Interface6 {
      field38: Boolean!
      field39: String
      field59: ID
    }
    
    type Object26 implements Interface6 {
      field38: Boolean!
      field39: String
      field61: Interface5
    }
    
    type Object27 {
      field113(argument55: ID): Interface3
      field114(argument56: Int, argument57: String, argument58: Int, argument59: String): Object36
      field63: Object28
      field74(argument24: ID): Interface1
      field75(argument25: Scalar1, argument26: [Enum2] = [EnumValue14], argument27: Int, argument28: String): Object5
      field76(argument29: Float, argument30: Float, argument31: Float = 1.0, argument32: [Enum2] = [EnumValue14], argument33: Int, argument34: String): Object5
      field77(argument35: Int, argument36: String): Object5
      field78(argument37: [ID]): [Interface4]!
      field79(argument38: [Enum1!]!, argument39: Int, argument40: String, argument41: Int, argument42: String): Object7
      field80(argument43: String, argument44: Int = 1, argument45: Int = 2, argument46: Boolean): Object30
      field98: Object32
    }
    
    type Object28 implements Interface3 {
      field13: ID!
      field64: String
      field65: Boolean!
      field66: [Object29]
    }
    
    type Object29 {
      field67: String!
      field68: String!
      field69: String
      field70: String
      field71: String
      field72: String
      field73: String
    }
    
    type Object3 {
      field6: String
      field7: Interface2
    }
    
    type Object30 implements Interface2 & Interface3 {
      field1: ID!
      field2: String!
      field3: Interface2
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field81: String
      field82: String
      field83: String!
      field84: String
      field85: Object31
      field95: [Object31]
      field96: [Object31]
      field97: [Object31]
    }
    
    type Object31 {
      field86: ID!
      field87: Enum3
      field88: String
      field89: String
      field90: String
      field91: String
      field92: Int
      field93: Int
      field94: String
    }
    
    type Object32 implements Interface2 & Interface3 & Interface5 {
      field1: ID!
      field100: String
      field101(argument47: Int, argument48: String, argument49: Int, argument50: String): Object33
      field112(argument51: Int, argument52: String, argument53: Int, argument54: String): Object7
      field2: String!
      field29: String
      field3: Interface2
      field30: String
      field31: String
      field32: String
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field99: String
    }
    
    type Object33 {
      field102: [Object34]
      field111: Object4
    }
    
    type Object34 {
      field103: String
      field104: Object35
    }
    
    type Object35 implements Interface2 & Interface3 & Interface4 {
      field1: ID!
      field105: [Interface5]
      field106: String!
      field107: [String!]
      field108: [String!]
      field109: [String!]
      field110: Interface1
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    type Object36 {
      field115: [Object37]
      field118: Object4
    }
    
    type Object37 {
      field116: String
      field117: Interface7
    }
    
    type Object4 {
      field10: Boolean!
      field11: Boolean!
      field12: String
      field9: String
    }
    
    type Object5 {
      field20: [Object6]
      field23: Object4
    }
    
    type Object6 {
      field21: String
      field22: Interface1
    }
    
    type Object7 {
      field34: [Object8]
      field37: Object4
    }
    
    type Object8 {
      field35: String
      field36: Interface4
    }
    
    type Object9 implements Interface1 & Interface2 & Interface3 & Interface4 {
      field1: ID!
      field14: String
      field15: String
      field16: String
      field17: String!
      field18: Scalar1
      field19(argument6: [Enum2] = [EnumValue14], argument7: Int, argument8: String): Object5
      field2: String!
      field24(argument10: [Enum2] = [EnumValue14], argument11: Int, argument12: String, argument9: Float = 1.0): Object5
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    enum Enum1 {
      EnumValue1
      EnumValue10
      EnumValue11
      EnumValue2
      EnumValue3
      EnumValue4
      EnumValue5
      EnumValue6
      EnumValue7
      EnumValue8
      EnumValue9
    }
    
    enum Enum2 {
      EnumValue12
      EnumValue13
      EnumValue14
      EnumValue15
      EnumValue16
      EnumValue17
    }
    
    enum Enum3 {
      EnumValue18
      EnumValue19
      EnumValue20
      EnumValue21
    }
    
    scalar Scalar1
    
    scalar Scalar2
    
    input InputObject1 {
      inputField1: String!
    }
    
    input InputObject10 {
      inputField35: ID!
    }
    
    input InputObject11 {
      inputField36: ID!
      inputField37: String
      inputField38: String
      inputField39: String
      inputField40: Boolean = true
    }
    
    input InputObject12 {
      inputField41: String
      inputField42: [Scalar2]
    }
    
    input InputObject2 {
      inputField2: String
      inputField3: String!
    }
    
    input InputObject3 {
      inputField4: ID!
      inputField5: Enum2!
      inputField6: String!
      inputField7: String
      inputField8: String
      inputField9: Scalar1
    }
    
    input InputObject4 {
      inputField10: ID!
      inputField11: Enum2!
      inputField12: String!
      inputField13: String
      inputField14: String
      inputField15: Scalar1
    }
    
    input InputObject5 {
      inputField16: ID!
      inputField17: String!
    }
    
    input InputObject6 {
      inputField18: ID!
      inputField19: String!
    }
    
    input InputObject7 {
      inputField20: ID!
      inputField21: String!
      inputField22: String
      inputField23: String!
      inputField24: [Scalar2]
      inputField25: InputObject8
    }
    
    input InputObject8 {
      inputField26: ID
      inputField27: String
      inputField28: Scalar1
    }
    
    input InputObject9 {
      inputField29: ID!
      inputField30: String
      inputField31: String!
      inputField32: [ID!]
      inputField33: [Scalar2]
      inputField34: InputObject8
    }
  6. andimarek commented on Feb 5, 2021

    @andimarek
    Member

    thanks @ntf : we would also need the query to actually benchmark it. Or can you not produce the anomymized query because of the error?

  7. ntf commented on Feb 5, 2021

    @ntf
    Author

    @andimarek
    Actually I can by clearing the error on the debugger.

    query operation {field113(argument55:"stringValue1") {... on Interface2 {__typename field1 field2 field3 {field2}}}}
    query FoobarQuery{
      node(id: "stringValue1") {
        ... on Thing {
          __typename
          id
          title
          parent {
            title
          }
        }
      }
    }
  8. bbakerman commented on Feb 8, 2021

    @bbakerman
    Member

    Commentary on this issue. Looking into the map usage here we have

            Map<Field, List<NormalizedField>> fieldToNormalizedField = new LinkedHashMap<>();
            Map<NormalizedField, MergedField> normalizedFieldToMergedField = new LinkedHashMap<>();
            Map<FieldCoordinates, List<NormalizedField>> coordinatesToNormalizedFields = new LinkedHashMap<>();
    

    at the top level of the processing. This is building out a map of all the NF -> to other things.

    In a large query this could indeed blow out with re-sizes since there could be lots of Fields.

    I cant see how the query listed above can cause this because its not very big. It has at most 6 fields. So this is making me wonder wether the FlightRecorder data is matching this query or not.

    But I havent run this up in a debugger etc.. so I cant say fo certain.

    One thought I have is that IF the validation code (which walks the query tree before hand - was to count how many nodes are present - then we could hint to later code to size structures better)

    And yes I know there is the much bigger idea of building the NF data at the same time as validation but thats much more work

  9. ntf commented on Feb 8, 2021

    @ntf
    Author

    @bbakerman

    How about this below ? I extracted from my frontend query to the backend.

    query operation($var1:ID) {field113(argument55:$var1) {__typename ... on Interface4 {alias1:__typename field25} ...Fragment1 ...Fragment5 field13} field98 {field1 ...Fragment6}} fragment Fragment1 on Interface2 {alias2:__typename field1 field2 field3 {__typename field1 field2} ... on Interface5 {alias3:__typename field30 field31} ... on Interface1 {alias4:__typename field14} ...Fragment2 ...Fragment3} fragment Fragment4 on Interface2 {alias5:__typename field1 field2 field3 {__typename field1} ... on Interface4 {alias6:__typename field25 field28 {__typename field1}}} fragment Fragment5 on Interface2 {alias7:__typename field1 field2 ... on Interface4 {alias8:__typename field25} field3 {__typename field1 field2 ... on Interface4 {alias9:__typename field25} ...Fragment3} ... on Interface1 {alias10:__typename field15 field16 field18}} fragment Fragment6 on Interface5 {alias11:__typename field1} fragment Fragment2 on Interface5 {alias12:__typename ...Fragment3} fragment Fragment3 on Interface2 {alias13:__typename ...Fragment4}
    schema {
      query: Object27
      mutation: Object23
    }
    
    "Directs the executor to include this field or fragment only when the `if` argument is true"
    directive @include(
        "Included when true."
        if: Boolean!
      ) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
    
    "Directs the executor to skip this field or fragment when the `if`'argument is true."
    directive @skip(
        "Skipped when true."
        if: Boolean!
      ) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
    
    directive @deprecated(reason: String) on FIELD_DEFINITION | ENUM_VALUE
    
    "Exposes a URL that specifies the behaviour of this scalar."
    directive @specifiedBy(
        "The URL that specifies the behaviour of this scalar."
        url: String!
      ) on SCALAR
    
    interface Interface1 implements Interface2 & Interface3 {
      field1: ID!
      field14: String
      field15: String
      field16: String
      field17: String!
      field18: Scalar1
      field19(argument6: [Enum2] = [EnumValue14], argument7: Int, argument8: String): Object5
      field2: String!
      field24(argument10: [Enum2] = [EnumValue14], argument11: Int, argument12: String, argument9: Float = 1.0): Object5
      field3: Interface2
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    interface Interface2 {
      field1: ID!
      field2: String!
      field3: Interface2
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    interface Interface3 {
      field13: ID!
    }
    
    interface Interface4 implements Interface2 & Interface3 {
      field1: ID!
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    interface Interface5 implements Interface2 & Interface3 {
      field1: ID!
      field2: String!
      field29: String
      field3: Interface2
      field30: String
      field31: String
      field32: String
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    interface Interface6 {
      field38: Boolean!
      field39: String
    }
    
    interface Interface7 {
      field45: ID!
      field46: String!
      field47: Int
      field48: String!
    }
    
    type Object1 implements Interface1 & Interface2 & Interface3 & Interface4 {
      field1: ID!
      field14: String
      field15: String
      field16: String
      field17: String!
      field18: Scalar1
      field19(argument6: [Enum2] = [EnumValue14], argument7: Int, argument8: String): Object5
      field2: String!
      field24(argument10: [Enum2] = [EnumValue14], argument11: Int, argument12: String, argument9: Float = 1.0): Object5
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    type Object10 implements Interface6 {
      field38: Boolean!
      field39: String
      field40: Object6
    }
    
    type Object11 implements Interface2 & Interface3 & Interface4 {
      field1: ID!
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field41: Interface1
    }
    
    type Object12 implements Interface2 & Interface3 & Interface4 {
      field1: ID!
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field42: String!
    }
    
    type Object13 implements Interface2 & Interface3 & Interface4 {
      field1: ID!
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    type Object14 implements Interface2 & Interface3 & Interface5 {
      field1: ID!
      field2: String!
      field29: String
      field3: Interface2
      field30: String
      field31: String
      field32: String
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    type Object15 implements Interface2 & Interface3 & Interface5 {
      field1: ID!
      field2: String!
      field29: String
      field3: Interface2
      field30: String
      field31: String
      field32: String
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    type Object16 implements Interface6 {
      field38: Boolean!
      field39: String
    }
    
    type Object17 {
      field43: [String!]
      field44: String!
    }
    
    type Object18 implements Interface2 & Interface3 & Interface4 & Interface7 {
      field1: ID!
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field48: String!
    }
    
    type Object19 implements Interface2 & Interface3 & Interface4 & Interface7 {
      field1: ID!
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field48: String!
    }
    
    type Object2 {
      field5: [Object3]
      field8: Object4
    }
    
    type Object20 implements Interface2 & Interface3 & Interface4 & Interface7 {
      field1: ID!
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field48: String!
    }
    
    type Object21 implements Interface2 & Interface3 & Interface4 & Interface7 {
      field1: ID!
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field48: String!
    }
    
    type Object22 implements Interface2 & Interface3 {
      field13: ID!
      field2: String!
      field3: Interface2
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    type Object23 {
      field49(argument13: InputObject3): Object24!
      field51(argument14: InputObject4): Object24!
      field52(argument15: InputObject3): Object24!
      field53(argument16: InputObject4): Object24!
      field54(argument17: InputObject5): Object24!
      field55(argument18: InputObject6): Object24!
      field56(argument19: InputObject7): Object24!
      field57(argument20: InputObject9): Object24!
      field58(argument21: InputObject10): Object25!
      field60(argument22: InputObject11): Object26!
      field62(argument23: InputObject12): Object24!
    }
    
    type Object24 implements Interface6 {
      field38: Boolean!
      field39: String
      field50: Object8
    }
    
    type Object25 implements Interface6 {
      field38: Boolean!
      field39: String
      field59: ID
    }
    
    type Object26 implements Interface6 {
      field38: Boolean!
      field39: String
      field61: Interface5
    }
    
    type Object27 {
      field113(argument55: ID): Interface3
      field114(argument56: Int, argument57: String, argument58: Int, argument59: String): Object36
      field63: Object28
      field74(argument24: ID): Interface1
      field75(argument25: Scalar1, argument26: [Enum2] = [EnumValue14], argument27: Int, argument28: String): Object5
      field76(argument29: Float, argument30: Float, argument31: Float = 1.0, argument32: [Enum2] = [EnumValue14], argument33: Int, argument34: String): Object5
      field77(argument35: Int, argument36: String): Object5
      field78(argument37: [ID]): [Interface4]!
      field79(argument38: [Enum1!]!, argument39: Int, argument40: String, argument41: Int, argument42: String): Object7
      field80(argument43: String, argument44: Int = 1, argument45: Int = 2, argument46: Boolean): Object30
      field98: Object32
    }
    
    type Object28 implements Interface3 {
      field13: ID!
      field64: String
      field65: Boolean!
      field66: [Object29]
    }
    
    type Object29 {
      field67: String!
      field68: String!
      field69: String
      field70: String
      field71: String
      field72: String
      field73: String
    }
    
    type Object3 {
      field6: String
      field7: Interface2
    }
    
    type Object30 implements Interface2 & Interface3 {
      field1: ID!
      field2: String!
      field3: Interface2
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field81: String
      field82: String
      field83: String!
      field84: String
      field85: Object31
      field95: [Object31]
      field96: [Object31]
      field97: [Object31]
    }
    
    type Object31 {
      field86: ID!
      field87: Enum3
      field88: String
      field89: String
      field90: String
      field91: String
      field92: Int
      field93: Int
      field94: String
    }
    
    type Object32 implements Interface2 & Interface3 & Interface5 {
      field1: ID!
      field100: String
      field101(argument47: Int, argument48: String, argument49: Int, argument50: String): Object33
      field112(argument51: Int, argument52: String, argument53: Int, argument54: String): Object7
      field2: String!
      field29: String
      field3: Interface2
      field30: String
      field31: String
      field32: String
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field99: String
    }
    
    type Object33 {
      field102: [Object34]
      field111: Object4
    }
    
    type Object34 {
      field103: String
      field104: Object35
    }
    
    type Object35 implements Interface2 & Interface3 & Interface4 {
      field1: ID!
      field105: [Interface5]
      field106: String!
      field107: [String!]
      field108: [String!]
      field109: [String!]
      field110: Interface1
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    type Object36 {
      field115: [Object37]
      field118: Object4
    }
    
    type Object37 {
      field116: String
      field117: Interface7
    }
    
    type Object4 {
      field10: Boolean!
      field11: Boolean!
      field12: String
      field9: String
    }
    
    type Object5 {
      field20: [Object6]
      field23: Object4
    }
    
    type Object6 {
      field21: String
      field22: Interface1
    }
    
    type Object7 {
      field34: [Object8]
      field37: Object4
    }
    
    type Object8 {
      field35: String
      field36: Interface4
    }
    
    type Object9 implements Interface1 & Interface2 & Interface3 & Interface4 {
      field1: ID!
      field14: String
      field15: String
      field16: String
      field17: String!
      field18: Scalar1
      field19(argument6: [Enum2] = [EnumValue14], argument7: Int, argument8: String): Object5
      field2: String!
      field24(argument10: [Enum2] = [EnumValue14], argument11: Int, argument12: String, argument9: Float = 1.0): Object5
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    enum Enum1 {
      EnumValue1
      EnumValue10
      EnumValue11
      EnumValue2
      EnumValue3
      EnumValue4
      EnumValue5
      EnumValue6
      EnumValue7
      EnumValue8
      EnumValue9
    }
    
    enum Enum2 {
      EnumValue12
      EnumValue13
      EnumValue14
      EnumValue15
      EnumValue16
      EnumValue17
    }
    
    enum Enum3 {
      EnumValue18
      EnumValue19
      EnumValue20
      EnumValue21
    }
    
    scalar Scalar1
    
    scalar Scalar2
    
    input InputObject1 {
      inputField1: String!
    }
    
    input InputObject10 {
      inputField35: ID!
    }
    
    input InputObject11 {
      inputField36: ID!
      inputField37: String
      inputField38: String
      inputField39: String
      inputField40: Boolean = true
    }
    
    input InputObject12 {
      inputField41: String
      inputField42: [Scalar2]
    }
    
    input InputObject2 {
      inputField2: String
      inputField3: String!
    }
    
    input InputObject3 {
      inputField4: ID!
      inputField5: Enum2!
      inputField6: String!
      inputField7: String
      inputField8: String
      inputField9: Scalar1
    }
    
    input InputObject4 {
      inputField10: ID!
      inputField11: Enum2!
      inputField12: String!
      inputField13: String
      inputField14: String
      inputField15: Scalar1
    }
    
    input InputObject5 {
      inputField16: ID!
      inputField17: String!
    }
    
    input InputObject6 {
      inputField18: ID!
      inputField19: String!
    }
    
    input InputObject7 {
      inputField20: ID!
      inputField21: String!
      inputField22: String
      inputField23: String!
      inputField24: [Scalar2]
      inputField25: InputObject8
    }
    
    input InputObject8 {
      inputField26: ID
      inputField27: String
      inputField28: Scalar1
    }
    
    input InputObject9 {
      inputField29: ID!
      inputField30: String
      inputField31: String!
      inputField32: [ID!]
      inputField33: [Scalar2]
      inputField34: InputObject8
    }
  10. bbakerman commented on Feb 8, 2021

    @bbakerman
    Member

    @andimarek - I tried to run up this schema from above. I think there might be a problem in the anonymizer code regarding interfaces and required fields etc...

    The interface type 'Interface1' [@26:1] does not have a field 'field13' required via interface 'Interface3' [@47:1]],
     
    The interface type 'Interface4' [@51:1] does not have a field 'field13' required via interface 'Interface3' [@47:1], 
    The interface type 'Interface5' [@63:1] does not have a field 'field13' required via interface 'Interface3' [@47:1],
     The object type 'Object1' [@86:1] does not have a field 'field25' required via interface 'Interface4' [@51:1],
     The object type 'Object1' [@86:1] does not have a field 'field13' required via interface 'Interface3' [@47:1], 
    The object type 'Object11' [@110:1] does not have a field 'field13' required via interface 'Interface3' [@47:1], 
    The object type 'Object12' [@123:1] does not have a field 'field13' required via interface 'Interface3' [@47:1],
     The object type 'Object13' [@136:1] does not have a field 'field13' required via interface 'Interface3' [@47:1],
     The object type 'Object14' [@148:1] does not have a field 'field13' required via interface 'Interface3' [@47:1], The object type 'Object15' [@159:1] does not have a field 'field13' required via interface 'Interface3' [@47:1], The object type 'Object18' [@180:1] does not have a field 'field45' required via interface 'Interface7' [@79:1], The object type 'Object18' [@180:1] does not have a field 'field46' required via interface 'Interface7' [@79:1], The object type 'Object18' [@180:1] does not have a field 'field47' required via interface 'Interface7' [@79:1], The object type 'Object18' [@180:1] does not have a field 'field13' required via interface 'Interface3' [@47:1], The object type 'Object19' [@193:1] does not have a field 'field45' required via interface 'Interface7' [@79:1], The object type 'Object19' [@193:1] does not have a field 'field46' required via interface 'Interface7' [@79:1], The object type 'Object19' [@193:1] does not have a field 'field47' required via interface 'Interface7' [@79:1], The object type 'Object19' [@193:1] does not have a field 'field13' required via interface 'Interface3' [@47:1], The object type 'Object20' [@211:1] does not have a field 'field45' required via interface 'Interface7' [@79:1], The object type 'Object20' [@211:1] does not have a field 'field46' required via interface 'Interface7' [@79:1], The object type 'Object20' [@211:1] does not have a field 'field47' required via interface 'Interface7' [@79:1], 
    

    The schema is not valid because of all the inheritance and fields not existing as required bu that inheritance.

  11. andimarek commented on Feb 13, 2021

    @andimarek
    Member

    Hi @ntf : can you please the latest dev version of the anonymizer: I identified and fixed a bug. See #2201

  12. ntf commented on Feb 13, 2021

    @ntf
    Author

    @andimarek , thanks for the patch. below output is based on version: 2021-02-13T02-14-19-a9de9cec

    errors: (24 of them)

    graphql.schema.validation.InvalidSchemaException: invalid schema:
    interface type 'Interface1' does not implement interface 'Interface3' because field 'field13' is missing
    interface type 'Interface4' does not implement interface 'Interface3' because field 'field13' is missing
    interface type 'Interface5' does not implement interface 'Interface3' because field 'field13' is missing
    object type 'Object1' does not implement interface 'Interface4' because field 'field25' is missing
    object type 'Object1' does not implement interface 'Interface3' because field 'field13' is missing
    object type 'Object11' does not implement interface 'Interface3' because field 'field13' is missing
    object type 'Object12' does not implement interface 'Interface3' because field 'field13' is missing
    object type 'Object13' does not implement interface 'Interface3' because field 'field13' is missing
    object type 'Object14' does not implement interface 'Interface3' because field 'field13' is missing
    object type 'Object15' does not implement interface 'Interface3' because field 'field13' is missing
    object type 'Object18' does not implement interface 'Interface7' because field 'field13' is missing
    object type 'Object18' does not implement interface 'Interface3' because field 'field13' is missing
    object type 'Object19' does not implement interface 'Interface7' because field 'field13' is missing
    object type 'Object19' does not implement interface 'Interface3' because field 'field13' is missing
    object type 'Object20' does not implement interface 'Interface7' because field 'field13' is missing
    object type 'Object20' does not implement interface 'Interface3' because field 'field13' is missing
    object type 'Object21' does not implement interface 'Interface7' because field 'field13' is missing
    object type 'Object21' does not implement interface 'Interface3' because field 'field13' is missing
    object type 'Object22' does not implement interface 'Interface2' because field 'field1' is missing
    object type 'Object30' does not implement interface 'Interface3' because field 'field13' is missing
    object type 'Object32' does not implement interface 'Interface3' because field 'field13' is missing
    object type 'Object35' does not implement interface 'Interface3' because field 'field13' is missing
    object type 'Object9' does not implement interface 'Interface4' because field 'field25' is missing
    object type 'Object9' does not implement interface 'Interface3' because field 'field13' is missing
    

    schema:

    schema {
      query: Object27
      mutation: Object23
    }
    
    "Directs the executor to include this field or fragment only when the `if` argument is true"
    directive @include(
        "Included when true."
        if: Boolean!
      ) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
    
    "Directs the executor to skip this field or fragment when the `if`'argument is true."
    directive @skip(
        "Skipped when true."
        if: Boolean!
      ) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
    
    directive @deprecated(reason: String) on FIELD_DEFINITION | ENUM_VALUE
    
    "Exposes a URL that specifies the behaviour of this scalar."
    directive @specifiedBy(
        "The URL that specifies the behaviour of this scalar."
        url: String!
      ) on SCALAR
    
    interface Interface1 implements Interface2 & Interface3 {
      field1: ID!
      field14: String
      field15: String
      field16: String
      field17: String!
      field18: Scalar1
      field19(argument6: [Enum2] = [EnumValue14], argument7: Int, argument8: String): Object5
      field2: String!
      field24(argument10: [Enum2] = [EnumValue14], argument11: Int, argument12: String, argument9: Float = 1.0): Object5
      field3: Interface2
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    interface Interface2 {
      field1: ID!
      field2: String!
      field3: Interface2
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    interface Interface3 {
      field13: ID!
    }
    
    interface Interface4 implements Interface2 & Interface3 {
      field1: ID!
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    interface Interface5 implements Interface2 & Interface3 {
      field1: ID!
      field2: String!
      field29: String
      field3: Interface2
      field30: String
      field31: String
      field32: String
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    interface Interface6 {
      field38: Boolean!
      field39: String
    }
    
    interface Interface7 {
      field13: ID!
      field25: String!
      field26: Int
      field45: String!
    }
    
    type Object1 implements Interface1 & Interface2 & Interface3 & Interface4 {
      field1: ID!
      field14: String
      field15: String
      field16: String
      field17: String!
      field18: Scalar1
      field19(argument6: [Enum2] = [EnumValue14], argument7: Int, argument8: String): Object5
      field2: String!
      field24(argument10: [Enum2] = [EnumValue14], argument11: Int, argument12: String, argument9: Float = 1.0): Object5
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    type Object10 implements Interface6 {
      field38: Boolean!
      field39: String
      field40: Object6
    }
    
    type Object11 implements Interface2 & Interface3 & Interface4 {
      field1: ID!
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field41: Interface1
    }
    
    type Object12 implements Interface2 & Interface3 & Interface4 {
      field1: ID!
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field42: String!
    }
    
    type Object13 implements Interface2 & Interface3 & Interface4 {
      field1: ID!
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    type Object14 implements Interface2 & Interface3 & Interface5 {
      field1: ID!
      field2: String!
      field29: String
      field3: Interface2
      field30: String
      field31: String
      field32: String
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    type Object15 implements Interface2 & Interface3 & Interface5 {
      field1: ID!
      field2: String!
      field29: String
      field3: Interface2
      field30: String
      field31: String
      field32: String
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    type Object16 implements Interface6 {
      field38: Boolean!
      field39: String
    }
    
    type Object17 {
      field43: [String!]
      field44: String!
    }
    
    type Object18 implements Interface2 & Interface3 & Interface4 & Interface7 {
      field1: ID!
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field45: String!
    }
    
    type Object19 implements Interface2 & Interface3 & Interface4 & Interface7 {
      field1: ID!
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field45: String!
    }
    
    type Object2 {
      field5: [Object3]
      field8: Object4
    }
    
    type Object20 implements Interface2 & Interface3 & Interface4 & Interface7 {
      field1: ID!
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field45: String!
    }
    
    type Object21 implements Interface2 & Interface3 & Interface4 & Interface7 {
      field1: ID!
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field45: String!
    }
    
    type Object22 implements Interface2 & Interface3 {
      field13: ID!
      field2: String!
      field3: Interface2
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    type Object23 {
      field46(argument13: InputObject3): Object24!
      field48(argument14: InputObject4): Object24!
      field49(argument15: InputObject3): Object24!
      field50(argument16: InputObject4): Object24!
      field51(argument17: InputObject5): Object24!
      field52(argument18: InputObject6): Object24!
      field53(argument19: InputObject7): Object24!
      field54(argument20: InputObject9): Object24!
      field55(argument21: InputObject10): Object25!
      field57(argument22: InputObject11): Object26!
      field59(argument23: InputObject12): Object24!
    }
    
    type Object24 implements Interface6 {
      field38: Boolean!
      field39: String
      field47: Object8
    }
    
    type Object25 implements Interface6 {
      field38: Boolean!
      field39: String
      field56: ID
    }
    
    type Object26 implements Interface6 {
      field38: Boolean!
      field39: String
      field58: Interface5
    }
    
    type Object27 {
      field110(argument55: ID): Interface3
      field111(argument56: Int, argument57: String, argument58: Int, argument59: String): Object36
      field60: Object28
      field71(argument24: ID): Interface1
      field72(argument25: Scalar1, argument26: [Enum2] = [EnumValue14], argument27: Int, argument28: String): Object5
      field73(argument29: Float, argument30: Float, argument31: Float = 1.0, argument32: [Enum2] = [EnumValue14], argument33: Int, argument34: String): Object5
      field74(argument35: Int, argument36: String): Object5
      field75(argument37: [ID]): [Interface4]!
      field76(argument38: [Enum1!]!, argument39: Int, argument40: String, argument41: Int, argument42: String): Object7
      field77(argument43: String, argument44: Int = 1, argument45: Int = 2, argument46: Boolean): Object30
      field95: Object32
    }
    
    type Object28 implements Interface3 {
      field13: ID!
      field61: String
      field62: Boolean!
      field63: [Object29]
    }
    
    type Object29 {
      field64: String!
      field65: String!
      field66: String
      field67: String
      field68: String
      field69: String
      field70: String
    }
    
    type Object3 {
      field6: String
      field7: Interface2
    }
    
    type Object30 implements Interface2 & Interface3 {
      field1: ID!
      field2: String!
      field3: Interface2
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field78: String
      field79: String
      field80: String!
      field81: String
      field82: Object31
      field92: [Object31]
      field93: [Object31]
      field94: [Object31]
    }
    
    type Object31 {
      field83: ID!
      field84: Enum3
      field85: String
      field86: String
      field87: String
      field88: String
      field89: Int
      field90: Int
      field91: String
    }
    
    type Object32 implements Interface2 & Interface3 & Interface5 {
      field1: ID!
      field109(argument51: Int, argument52: String, argument53: Int, argument54: String): Object7
      field2: String!
      field29: String
      field3: Interface2
      field30: String
      field31: String
      field32: String
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field96: String
      field97: String
      field98(argument47: Int, argument48: String, argument49: Int, argument50: String): Object33
    }
    
    type Object33 {
      field108: Object4
      field99: [Object34]
    }
    
    type Object34 {
      field100: String
      field101: Object35
    }
    
    type Object35 implements Interface2 & Interface3 & Interface4 {
      field1: ID!
      field102: [Interface5]
      field103: String!
      field104: [String!]
      field105: [String!]
      field106: [String!]
      field107: Interface1
      field2: String!
      field25: String!
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    type Object36 {
      field112: [Object37]
      field115: Object4
    }
    
    type Object37 {
      field113: String
      field114: Interface7
    }
    
    type Object4 {
      field10: Boolean!
      field11: Boolean!
      field12: String
      field9: String
    }
    
    type Object5 {
      field20: [Object6]
      field23: Object4
    }
    
    type Object6 {
      field21: String
      field22: Interface1
    }
    
    type Object7 {
      field34: [Object8]
      field37: Object4
    }
    
    type Object8 {
      field35: String
      field36: Interface4
    }
    
    type Object9 implements Interface1 & Interface2 & Interface3 & Interface4 {
      field1: ID!
      field14: String
      field15: String
      field16: String
      field17: String!
      field18: Scalar1
      field19(argument6: [Enum2] = [EnumValue14], argument7: Int, argument8: String): Object5
      field2: String!
      field24(argument10: [Enum2] = [EnumValue14], argument11: Int, argument12: String, argument9: Float = 1.0): Object5
      field26: Int
      field27: Int
      field28: Interface5
      field3: Interface2
      field33: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    enum Enum1 {
      EnumValue1
      EnumValue10
      EnumValue11
      EnumValue2
      EnumValue3
      EnumValue4
      EnumValue5
      EnumValue6
      EnumValue7
      EnumValue8
      EnumValue9
    }
    
    enum Enum2 {
      EnumValue12
      EnumValue13
      EnumValue14
      EnumValue15
      EnumValue16
      EnumValue17
    }
    
    enum Enum3 {
      EnumValue18
      EnumValue19
      EnumValue20
      EnumValue21
    }
    
    scalar Scalar1
    
    scalar Scalar2
    
    input InputObject1 {
      inputField1: String!
    }
    
    input InputObject10 {
      inputField35: ID!
    }
    
    input InputObject11 {
      inputField36: ID!
      inputField37: String
      inputField38: String
      inputField39: String
      inputField40: Boolean = true
    }
    
    input InputObject12 {
      inputField41: String
      inputField42: [Scalar2]
    }
    
    input InputObject2 {
      inputField2: String
      inputField3: String!
    }
    
    input InputObject3 {
      inputField4: ID!
      inputField5: Enum2!
      inputField6: String!
      inputField7: String
      inputField8: String
      inputField9: Scalar1
    }
    
    input InputObject4 {
      inputField10: ID!
      inputField11: Enum2!
      inputField12: String!
      inputField13: String
      inputField14: String
      inputField15: Scalar1
    }
    
    input InputObject5 {
      inputField16: ID!
      inputField17: String!
    }
    
    input InputObject6 {
      inputField18: ID!
      inputField19: String!
    }
    
    input InputObject7 {
      inputField20: ID!
      inputField21: String!
      inputField22: String
      inputField23: String!
      inputField24: [Scalar2]
      inputField25: InputObject8
    }
    
    input InputObject8 {
      inputField26: ID
      inputField27: String
      inputField28: Scalar1
    }
    
    input InputObject9 {
      inputField29: ID!
      inputField30: String
      inputField31: String!
      inputField32: [ID!]
      inputField33: [Scalar2]
      inputField34: InputObject8
    }

    query:

    query operation {...Fragment1 ...Fragment2 ...Fragment3} fragment Fragment3 on Object27 {field95 {field31 field32 field29 field1} field60 {field61 field62 field13}} fragment Fragment2 on Object27 {field95 {field31 field32 field29 field1} field60 {field61 field62 field13}} fragment Fragment1 on Object27 {field95 {field29 field1} field60 {field61 field62 field13}}
  13. andimarek commented on Feb 13, 2021

    @andimarek
    Member

    Thanks @ntf, but exactly the same bug I fixed seems to be still present.

    Can you confirm that your are using the version you mentioned?
    If so, can you anonomyize the small Schema from this test: https://github.com/graphql-java/graphql-java/blob/master/src/test/groovy/graphql/util/AnonymizerTest.groovy#L550

    Thanks for your help!

  14. ntf commented on Feb 13, 2021

    @ntf
    Author

    input:

    Anonymizer.anonymizeSchema(new SchemaGenerator().makeExecutableSchema(
            new SchemaParser()
                    .parse("  type Query {                 foo: Object             } interface Interface1 implements Interface2 & Interface3 {   id: ID! } interface Interface2 {   id: ID! } interface Interface3 {   id: ID! } type Object implements Interface1 & Interface2 & Interface3 {   id: ID! }"),
            RuntimeWiring.newRuntimeWiring()
                    .type(TypeRuntimeWiring.newTypeWiring("Interface1")
                            .typeResolver(new DefaultTypeResolver()))
                    .type(TypeRuntimeWiring.newTypeWiring("Interface2")
                            .typeResolver(new DefaultTypeResolver()))
                    .type(TypeRuntimeWiring.newTypeWiring("Interface3")
                            .typeResolver(new DefaultTypeResolver()))
                    .build()
    ))

    output:

    schema {
      query: Object1
    }
    
    "Directs the executor to include this field or fragment only when the `if` argument is true"
    directive @include(
        "Included when true."
        if: Boolean!
      ) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
    
    "Directs the executor to skip this field or fragment when the `if`'argument is true."
    directive @skip(
        "Skipped when true."
        if: Boolean!
      ) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
    
    directive @deprecated(reason: String) on FIELD_DEFINITION | ENUM_VALUE
    
    "Exposes a URL that specifies the behaviour of this scalar."
    directive @specifiedBy(
        "The URL that specifies the behaviour of this scalar."
        url: String!
      ) on SCALAR
    
    interface Interface1 implements Interface2 & Interface3 {
      field2: ID!
    }
    
    interface Interface2 {
      field2: ID!
    }
    
    interface Interface3 {
      field2: ID!
    }
    
    type Object1 {
      field1: Object2
    }
    
    type Object2 implements Interface1 & Interface2 & Interface3 {
      field2: ID!
    }
  15. andimarek commented on Feb 13, 2021

    @andimarek
    Member

    I can see that my fix worked only partially. Thanks to your schema I just merged another bugfix #2202 which hopefully should fix the problem for good 🤞
    Please try again ... thanks a lot @ntf

  16. ntf commented on Feb 14, 2021

    @ntf
    Author

    @andimarek , congratulation! The fix #2202 works on my schema!

    version: 2021-02-13T23-17-27-86627c27

    schema {
      query: Object27
      mutation: Object23
    }
    
    "Directs the executor to include this field or fragment only when the `if` argument is true"
    directive @include(
        "Included when true."
        if: Boolean!
      ) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
    
    "Directs the executor to skip this field or fragment when the `if`'argument is true."
    directive @skip(
        "Skipped when true."
        if: Boolean!
      ) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
    
    directive @deprecated(reason: String) on FIELD_DEFINITION | ENUM_VALUE
    
    "Exposes a URL that specifies the behaviour of this scalar."
    directive @specifiedBy(
        "The URL that specifies the behaviour of this scalar."
        url: String!
      ) on SCALAR
    
    interface Interface1 implements Interface2 & Interface3 {
      field1: ID!
      field13: String
      field14: String
      field15: String
      field16: String!
      field17: Scalar1
      field18(argument6: [Enum2] = [EnumValue14], argument7: Int, argument8: String): Object5
      field2: String!
      field23(argument10: [Enum2] = [EnumValue14], argument11: Int, argument12: String, argument9: Float = 1.0): Object5
      field3: Interface2
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    interface Interface2 {
      field1: ID!
      field2: String!
      field3: Interface2
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    interface Interface3 {
      field1: ID!
    }
    
    interface Interface4 implements Interface2 & Interface3 {
      field1: ID!
      field16: String!
      field2: String!
      field24: Int
      field25: Int
      field26: Interface5
      field3: Interface2
      field31: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    interface Interface5 implements Interface2 & Interface3 {
      field1: ID!
      field2: String!
      field27: String
      field28: String
      field29: String
      field3: Interface2
      field30: String
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    interface Interface6 {
      field36: Boolean!
      field37: String
    }
    
    interface Interface7 {
      field1: ID!
      field16: String!
      field24: Int
      field40: String!
    }
    
    type Object1 implements Interface1 & Interface2 & Interface3 & Interface4 {
      field1: ID!
      field13: String
      field14: String
      field15: String
      field16: String!
      field17: Scalar1
      field18(argument6: [Enum2] = [EnumValue14], argument7: Int, argument8: String): Object5
      field2: String!
      field23(argument10: [Enum2] = [EnumValue14], argument11: Int, argument12: String, argument9: Float = 1.0): Object5
      field24: Int
      field25: Int
      field26: Interface5
      field3: Interface2
      field31: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    type Object10 implements Interface6 {
      field36: Boolean!
      field37: String
      field38: Object6
    }
    
    type Object11 implements Interface2 & Interface3 & Interface4 {
      field1: ID!
      field16: String!
      field2: String!
      field24: Int
      field25: Int
      field26: Interface5
      field3: Interface2
      field31: Object7
      field39: Interface1
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    type Object12 implements Interface2 & Interface3 & Interface4 {
      field1: ID!
      field16: String!
      field2: String!
      field24: Int
      field25: Int
      field26: Interface5
      field3: Interface2
      field31: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field40: String!
    }
    
    type Object13 implements Interface2 & Interface3 & Interface4 {
      field1: ID!
      field16: String!
      field2: String!
      field24: Int
      field25: Int
      field26: Interface5
      field3: Interface2
      field31: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    type Object14 implements Interface2 & Interface3 & Interface5 {
      field1: ID!
      field2: String!
      field27: String
      field28: String
      field29: String
      field3: Interface2
      field30: String
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    type Object15 implements Interface2 & Interface3 & Interface5 {
      field1: ID!
      field2: String!
      field27: String
      field28: String
      field29: String
      field3: Interface2
      field30: String
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    type Object16 implements Interface6 {
      field36: Boolean!
      field37: String
    }
    
    type Object17 {
      field41: [String!]
      field42: String!
    }
    
    type Object18 implements Interface2 & Interface3 & Interface4 & Interface7 {
      field1: ID!
      field16: String!
      field2: String!
      field24: Int
      field25: Int
      field26: Interface5
      field3: Interface2
      field31: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field40: String!
    }
    
    type Object19 implements Interface2 & Interface3 & Interface4 & Interface7 {
      field1: ID!
      field16: String!
      field2: String!
      field24: Int
      field25: Int
      field26: Interface5
      field3: Interface2
      field31: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field40: String!
    }
    
    type Object2 {
      field5: [Object3]
      field8: Object4
    }
    
    type Object20 implements Interface2 & Interface3 & Interface4 & Interface7 {
      field1: ID!
      field16: String!
      field2: String!
      field24: Int
      field25: Int
      field26: Interface5
      field3: Interface2
      field31: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field40: String!
    }
    
    type Object21 implements Interface2 & Interface3 & Interface4 & Interface7 {
      field1: ID!
      field16: String!
      field2: String!
      field24: Int
      field25: Int
      field26: Interface5
      field3: Interface2
      field31: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field40: String!
    }
    
    type Object22 implements Interface2 & Interface3 {
      field1: ID!
      field2: String!
      field3: Interface2
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    type Object23 {
      field43(argument13: InputObject3): Object24!
      field45(argument14: InputObject4): Object24!
      field46(argument15: InputObject3): Object24!
      field47(argument16: InputObject4): Object24!
      field48(argument17: InputObject5): Object24!
      field49(argument18: InputObject6): Object24!
      field50(argument19: InputObject7): Object24!
      field51(argument20: InputObject9): Object24!
      field52(argument21: InputObject10): Object25!
      field54(argument22: InputObject11): Object26!
      field56(argument23: InputObject12): Object24!
    }
    
    type Object24 implements Interface6 {
      field36: Boolean!
      field37: String
      field44: Object8
    }
    
    type Object25 implements Interface6 {
      field36: Boolean!
      field37: String
      field53: ID
    }
    
    type Object26 implements Interface6 {
      field36: Boolean!
      field37: String
      field55: Interface5
    }
    
    type Object27 {
      field105(argument55: ID): Interface3
      field106(argument56: Int, argument57: String, argument58: Int, argument59: String): Object36
      field57: Object28
      field68(argument24: ID): Interface1
      field69(argument25: Scalar1, argument26: [Enum2] = [EnumValue14], argument27: Int, argument28: String): Object5
      field70(argument29: Float, argument30: Float, argument31: Float = 1.0, argument32: [Enum2] = [EnumValue14], argument33: Int, argument34: String): Object5
      field71(argument35: Int, argument36: String): Object5
      field72(argument37: [ID]): [Interface4]!
      field73(argument38: [Enum1!]!, argument39: Int, argument40: String, argument41: Int, argument42: String): Object7
      field74(argument43: String, argument44: Int = 1, argument45: Int = 2, argument46: Boolean): Object30
      field91: Object32
    }
    
    type Object28 implements Interface3 {
      field1: ID!
      field58: String
      field59: Boolean!
      field60: [Object29]
    }
    
    type Object29 {
      field61: String!
      field62: String!
      field63: String
      field64: String
      field65: String
      field66: String
      field67: String
    }
    
    type Object3 {
      field6: String
      field7: Interface2
    }
    
    type Object30 implements Interface2 & Interface3 {
      field1: ID!
      field14: String
      field2: String!
      field3: Interface2
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field75: String
      field76: String
      field77: String!
      field78: Object31
      field88: [Object31]
      field89: [Object31]
      field90: [Object31]
    }
    
    type Object31 {
      field79: ID!
      field80: Enum3
      field81: String
      field82: String
      field83: String
      field84: String
      field85: Int
      field86: Int
      field87: String
    }
    
    type Object32 implements Interface2 & Interface3 & Interface5 {
      field1: ID!
      field104(argument51: Int, argument52: String, argument53: Int, argument54: String): Object7
      field2: String!
      field27: String
      field28: String
      field29: String
      field3: Interface2
      field30: String
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field92: String
      field93: String
      field94(argument47: Int, argument48: String, argument49: Int, argument50: String): Object33
    }
    
    type Object33 {
      field103: Object4
      field95: [Object34]
    }
    
    type Object34 {
      field96: String
      field97: Object35
    }
    
    type Object35 implements Interface2 & Interface3 & Interface4 {
      field1: ID!
      field100: [String!]
      field101: [String!]
      field102: [String!]
      field16: String!
      field2: String!
      field24: Int
      field25: Int
      field26: Interface5
      field3: Interface2
      field31: Object7
      field39: Interface1
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
      field98: [Interface5]
      field99: String!
    }
    
    type Object36 {
      field107: [Object37]
      field110: Object4
    }
    
    type Object37 {
      field108: String
      field109: Interface7
    }
    
    type Object4 {
      field10: Boolean!
      field11: Boolean!
      field12: String
      field9: String
    }
    
    type Object5 {
      field19: [Object6]
      field22: Object4
    }
    
    type Object6 {
      field20: String
      field21: Interface1
    }
    
    type Object7 {
      field32: [Object8]
      field35: Object4
    }
    
    type Object8 {
      field33: String
      field34: Interface4
    }
    
    type Object9 implements Interface1 & Interface2 & Interface3 & Interface4 {
      field1: ID!
      field13: String
      field14: String
      field15: String
      field16: String!
      field17: Scalar1
      field18(argument6: [Enum2] = [EnumValue14], argument7: Int, argument8: String): Object5
      field2: String!
      field23(argument10: [Enum2] = [EnumValue14], argument11: Int, argument12: String, argument9: Float = 1.0): Object5
      field24: Int
      field25: Int
      field26: Interface5
      field3: Interface2
      field31: Object7
      field4(argument1: [Enum1!] = [EnumValue1], argument2: Int, argument3: String, argument4: Int, argument5: String): Object2
    }
    
    enum Enum1 {
      EnumValue1
      EnumValue10
      EnumValue11
      EnumValue2
      EnumValue3
      EnumValue4
      EnumValue5
      EnumValue6
      EnumValue7
      EnumValue8
      EnumValue9
    }
    
    enum Enum2 {
      EnumValue12
      EnumValue13
      EnumValue14
      EnumValue15
      EnumValue16
      EnumValue17
    }
    
    enum Enum3 {
      EnumValue18
      EnumValue19
      EnumValue20
      EnumValue21
    }
    
    scalar Scalar1
    
    scalar Scalar2
    
    input InputObject1 {
      inputField1: String!
    }
    
    input InputObject10 {
      inputField35: ID!
    }
    
    input InputObject11 {
      inputField36: ID!
      inputField37: String
      inputField38: String
      inputField39: String
      inputField40: Boolean = true
    }
    
    input InputObject12 {
      inputField41: String
      inputField42: [Scalar2]
    }
    
    input InputObject2 {
      inputField2: String
      inputField3: String!
    }
    
    input InputObject3 {
      inputField4: ID!
      inputField5: Enum2!
      inputField6: String!
      inputField7: String
      inputField8: String
      inputField9: Scalar1
    }
    
    input InputObject4 {
      inputField10: ID!
      inputField11: Enum2!
      inputField12: String!
      inputField13: String
      inputField14: String
      inputField15: Scalar1
    }
    
    input InputObject5 {
      inputField16: ID!
      inputField17: String!
    }
    
    input InputObject6 {
      inputField18: ID!
      inputField19: String!
    }
    
    input InputObject7 {
      inputField20: ID!
      inputField21: String!
      inputField22: String
      inputField23: String!
      inputField24: [Scalar2]
      inputField25: InputObject8
    }
    
    input InputObject8 {
      inputField26: ID
      inputField27: String
      inputField28: Scalar1
    }
    
    input InputObject9 {
      inputField29: ID!
      inputField30: String
      inputField31: String!
      inputField32: [ID!]
      inputField33: [Scalar2]
      inputField34: InputObject8
    }

    query:

    query operation {...Fragment1 ...Fragment2 ...Fragment3} fragment Fragment3 on Object27 {field91 {field29 field30 field27 field1} field57 {field58 field59 field1}} fragment Fragment2 on Object27 {field91 {field29 field30 field27 field1} field57 {field58 field59 field1}} fragment Fragment1 on Object27 {field91 {field27 field1} field57 {field58 field59 field1}}
    
  17. aleksandarsusnjar commented on May 11, 2021

    @aleksandarsusnjar

    Seems related: #2309

  18. ntf commented on May 12, 2021

    @ntf
    Author

    @aleksandarsusnjar I think it is related.
    meanwhile I just downgraded to 15.0 so that I can continue to work on the project.

  19. aleksandarsusnjar commented on May 12, 2021

    @aleksandarsusnjar

    @andimarek: You said:

    @ntf in general we are aware that selectionSet is more compute intense now. That is the price we paid to be able to handle general lookups (including aliases and interfaces/unions).

    Can you be more specific about the gains, esp. related to my question here: #2331 (is that supposed to work)?

    I think you are "overnormalizing". In reality only a small subset of all possible relationships will be materialized in (almost) any recursive schema, yet you are materializing all possibilities upfront. I think it would be a lot better if you didn't ... You need to let us, users of graphql-java take our responsibility for knowing what to fetch (in fact, overnormalizing it makes it harder, I had to implement code to perform the inverse) and then you can lazily get only the stuff you discover in the actual fetched data ...

    ... and to qualify what makes it harder... my type hierarchies map to DB tables eventually. They include abstract/base types too with tables that contain data for these abstract/base types. By exploding all possible relationships you make it hard for me to discover that it really is just that column from that table in the end because it may be listed hundreds of times for different types. I have to walk my model back up to discover ... oh ... these hundred selected fields are really just this one here, from this type, so that I could build efficient queries.

  20. andimarek commented on May 19, 2021

    @andimarek
    Member

    Hi @ntf and @aleksandarsusnjar : please have a look at this PR #2345 which aims to solve this issue here. The plan is to get this PR merged soon. It would be great if you could provide early feedback if this solves your problem. Thanks

  21. aleksandarsusnjar commented on May 19, 2021

    @aleksandarsusnjar

    @andimarek Will do!

  22. andimarek commented on May 20, 2021

    @andimarek
    Member

    the PR is now merged and the dev build contains the improvements @ntf @aleksandarsusnjar

  23. ntf commented on May 20, 2021

    @ntf
    Author

    Thanks, @andimarek . Which dev build contains the changes?

    the latest one I can find on Maven central is https://search.maven.org/artifact/com.graphql-java/graphql-java/0.0.0-2021-05-17T23-49-29-83942204/jar

  24. andimarek commented on May 21, 2021

    @andimarek
    Member
  25. ntf commented on Jun 28, 2021

    @ntf
    Author

    Hi @andimarek, sorry for the delay.

    It seems the DataFetchingEnvironment#selectionSet() now resolves fields lazily upon accessing environment.getSelectionSet().getFields() and that finishes instantly.

    I verified that this fixed my issue originally raised on Feb.

    Edit: Got an NPE "java.lang.NullPointerException: null value in entry: viewAs=null" for the below

    type XXX {
        owners(viewAs: ID = null): YYYConnection
    }

    graphql.com.google.common.collect.CollectPreconditions.checkEntryNotNull(CollectPreconditions.java:32)
    ....
    graphql.com.google.common.collect.ImmutableMap.copyOf(ImmutableMap.java:438)
    graphql.normalized.NormalizedField$Builder.resolvedArguments(NormalizedField.java:310)

            public Builder resolvedArguments(@Nullable Map<String, Object> arguments) {
                this.resolvedArguments = arguments == null ? ImmutableKit.emptyMap() : ImmutableMap.copyOf(arguments);
                return this;
            }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions