Skip to content

Composition failure due to failed assertion (UNKNOWN: Should not have been called for ...) if an @external field has an argument with default list value #3244

@vvd170501

Description

@vvd170501

Issue Description

Hi,
I'm trying to understand how @external works with arguments. It seems there's a bug when a supergraph is being composed from subgraphs that:

  1. Have an object type with shared field
  2. This field has an argument with non-scalar type (list or input object) and a default value
  3. The field is marked @external in at least one subgraph

Example

# subgraph1.graphql                          
extend schema
  @link(
    url: "https://specs.apollo.dev/federation/v2.3",
    import: [
      "@shareable",
    ]
  )

input IntWrapper {
  value: Int
}

type Foo {
  good(x: Int = 1): Int @shareable
  bad1(x: IntWrapper = {value: 1}): Int @shareable
  bad2(x: [Int] = [1]): Int @shareable
}

type Query {
  foo: Int
}
# subgraph2.graphql                          
extend schema
  @link(
    url: "https://specs.apollo.dev/federation/v2.3",
    import: [
      "@external",
      "@requires",
    ]
  )

input IntWrapper {
  value: Int
}

type Foo {
  good(x: Int = 1): Int @external
  bad1(x: IntWrapper = {value: 1}): Int @external
  bad2(x: [Int] = [1]): Int @external

  foo: Int @requires(fields: "good(x: 123)")
  bar: Int @requires(fields: "bad1(x: {value: 123})")
  baz: Int @requires(fields: "bad2(x: [123])")
}

I try to compose these files using rover supergraph compose with the following config:

subgraphs:
  subgraph1:
    routing_url: http://localhost:4000
    schema:
      file: ./subgraph1.graphql
  subgraph2:
    routing_url: http://localhost:4001
    schema:
      file: ./subgraph2.graphql

The composition fails with UNKNOWN: Should not have been called for x: IntWrapper = {value: 1}.

  • If bad1 and bar are removed from subgraph2, it fails with UNKNOWN: Should not have been called for x: [Int] = [1].
  • If bad2 and baz are also removed, the composition succeeds (does not seem to reproduce with scalar fields).
  • If default values for bad1 and bad2 are removed in all subgraphs, the composition also succeeds.

I've searched for error text and it seems that the error is an assertion failure from this line.

Link to Reproduction

None (I've only tried composing supergraphs with rover)

Reproduction Steps

No response

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