code: function skipRedundantNodesTransform(
    context: GraphQLCompilerContext,
  ): GraphQLCompilerContext {
    return GraphQLIRTransformer.transform(context, {
      Root: visitNode,
      Fragment: visitNode,
    });
  }
docs: A transform that removes redundant fields and fragment spreads. Redundancy is
  defined in this context as any selection that is guaranteed to already be
  fetched by an ancestor selection. This can occur in two cases:
  
  1. Simple duplicates at the same level of the document can always be skipped:
  
  ```
  fragment Foo on FooType {
  id
  id
  ...Bar
  ...Bar
  }
  ```
  
  Becomes
  
  ```
  fragment Foo on FooType {
  id
  ...Bar
  }
  ```
  
  2. Inline fragments and conditions introduce the possibility for duplication
  at different levels of the tree. Whenever a selection is fetched in a parent,
  it is redundant to also fetch it in a child:
  
  ```
  fragment Foo on FooType {
  id
  ... on OtherType {
  id # 1
  }
  ... on FooType @include(if: $cond) {
  id # 2
  }
  }
  ```
  
  Becomes:
  
  ```
  fragment Foo on FooType {
  id
  }
  ```
  
  In this example:
  - 1 can be skipped because `id` is already fetched by the parent. Even
  though the type is different (FooType/OtherType), the inline fragment
  cannot match without the outer fragment matching so the outer `id` is
  guaranteed to already be fetched.
  - 2 can be skipped for similar reasons: it doesn't matter if the condition
  holds, `id` is already fetched by the parent regardless.
  
  This transform also handles more complicated cases in which selections are
  nested:
  
  ```
  fragment Foo on FooType {
  a {
  bb
  }
  ... on OtherType {
  a {
  bb # 1
  cc
  }
  }
  }
  ```
  
  Becomes
  
  ```
  fragment Foo on FooType {
  a {
  bb
  }
  ... on OtherType {
  a {
  cc
  }
  }
  }
  ```
  
  1 can be skipped because it is already fetched at the outer level.