github ardatan/graphql-tools release-1714135357803
April 26, 2024

latest releases: release-1731080717646, @graphql-tools/url-loader@8.0.14, @graphql-tools/prisma-loader@8.0.16...
6 months ago

@graphql-tools/delegate@10.0.5

Patch Changes

  • #6091 9bca9e0 Thanks @User, @User! - If the gateway receives a query with an overlapping fields for the subschema, it uses aliases to resolve it correctly.

    Let's say subschema A has the following schema;

      type Query {
    
      }
    
      interface User {
        id: ID!
        name: String!
      }
    
      type Admin implements User {
        id: ID!
        name: String!
        role: String!
      }
    
      type Customer implements User {
        id: ID!
        name: String
        email: String
      }

    And let's say the gateway has the following schema instead;

      type Query {
    
      }
    
      interface User {
        id: ID!
        name: String!
      }
    
      type Admin implements User {
        id: ID!
        name: String!
        role: String!
      }
    
      type Customer implements User {
        id: ID!
        name: String!
        email: String!
      }

    In this case, the following query is fine for the gateway but for the subschema, it's not;

    query {
      user {
        ... on Admin {
          id
          name # This is nullable in the subschema
          role
        }
        ... on Customer {
          id
          name # This is non-nullable in the subschema
          email
        }
      }
    }

    So the subgraph will throw based on this rule OverlappingFieldsCanBeMerged

    To avoid this, the gateway will use aliases to resolve the query correctly. The query will be transformed to the following;

    query {
      user {
        ... on Admin {
          id
          name # This is nullable in the subschema
          role
        }
        ... on Customer {
          id
          name: _nullable_name # This is non-nullable in the subschema
          email
        }
      }
    }
  • #6092 243c353 Thanks @ardatan! - If one of the subgraphs are already able to resolve a nested field as in parent-entity-call example's Category.details from C's Product, resolve it from there instead of using type merging.

    query {
      product {
        category {
          details {
            # This is coming from C's Product, so resolve it from there instead of Type Merging
            id
            name
          }
        }
      }
    }

@graphql-tools/federation@1.1.28

Patch Changes

  • #6091 9bca9e0 Thanks @User, @User! - If the gateway receives a query with an overlapping fields for the subschema, it uses aliases to resolve it correctly.

    Let's say subschema A has the following schema;

      type Query {
    
      }
    
      interface User {
        id: ID!
        name: String!
      }
    
      type Admin implements User {
        id: ID!
        name: String!
        role: String!
      }
    
      type Customer implements User {
        id: ID!
        name: String
        email: String
      }

    And let's say the gateway has the following schema instead;

      type Query {
    
      }
    
      interface User {
        id: ID!
        name: String!
      }
    
      type Admin implements User {
        id: ID!
        name: String!
        role: String!
      }
    
      type Customer implements User {
        id: ID!
        name: String!
        email: String!
      }

    In this case, the following query is fine for the gateway but for the subschema, it's not;

    query {
      user {
        ... on Admin {
          id
          name # This is nullable in the subschema
          role
        }
        ... on Customer {
          id
          name # This is non-nullable in the subschema
          email
        }
      }
    }

    So the subgraph will throw based on this rule OverlappingFieldsCanBeMerged

    To avoid this, the gateway will use aliases to resolve the query correctly. The query will be transformed to the following;

    query {
      user {
        ... on Admin {
          id
          name # This is nullable in the subschema
          role
        }
        ... on Customer {
          id
          name: _nullable_name # This is non-nullable in the subschema
          email
        }
      }
    }
  • Updated dependencies [9bca9e0, 9bca9e0, 243c353]:

    • @graphql-tools/stitch@9.2.0
    • @graphql-tools/delegate@10.0.5

@graphql-tools/stitch@9.2.0

Minor Changes

  • #6091 9bca9e0 Thanks @User, @User! - New option useNonNullableFieldOnConflict in typeMergingOptions of stitchSchemas

    When you have two schemas like below, you will get a warning about the conflicting fields because name field is defined as non-null in one schema and nullable in the other schema, and non-nullable field can exist in the stitched schema because of the order or any other reasons, and this might actually cause an unexpected behavior when you fetch User.name from the one who has it as non-nullable.
    This option supresses the warning, and takes the field from the schema that has it as non-nullable.

      type Query {
    
      }
    
      type User {
        id: ID!
        name: String
        email: String
      }

    And;

      type Query {
    
      }
    
      type User {
        id: ID!
        name: String!
      }

Patch Changes

  • #6091 9bca9e0 Thanks @User, @User! - If the gateway receives a query with an overlapping fields for the subschema, it uses aliases to resolve it correctly.

    Let's say subschema A has the following schema;

      type Query {
    
      }
    
      interface User {
        id: ID!
        name: String!
      }
    
      type Admin implements User {
        id: ID!
        name: String!
        role: String!
      }
    
      type Customer implements User {
        id: ID!
        name: String
        email: String
      }

    And let's say the gateway has the following schema instead;

      type Query {
    
      }
    
      interface User {
        id: ID!
        name: String!
      }
    
      type Admin implements User {
        id: ID!
        name: String!
        role: String!
      }
    
      type Customer implements User {
        id: ID!
        name: String!
        email: String!
      }

    In this case, the following query is fine for the gateway but for the subschema, it's not;

    query {
      user {
        ... on Admin {
          id
          name # This is nullable in the subschema
          role
        }
        ... on Customer {
          id
          name # This is non-nullable in the subschema
          email
        }
      }
    }

    So the subgraph will throw based on this rule OverlappingFieldsCanBeMerged

    To avoid this, the gateway will use aliases to resolve the query correctly. The query will be transformed to the following;

    query {
      user {
        ... on Admin {
          id
          name # This is nullable in the subschema
          role
        }
        ... on Customer {
          id
          name: _nullable_name # This is non-nullable in the subschema
          email
        }
      }
    }
  • #6092 243c353 Thanks @ardatan! - If one of the subgraphs are already able to resolve a nested field as in parent-entity-call example's Category.details from C's Product, resolve it from there instead of using type merging.

    query {
      product {
        category {
          details {
            # This is coming from C's Product, so resolve it from there instead of Type Merging
            id
            name
          }
        }
      }
    }
  • Updated dependencies [9bca9e0, 243c353]:

    • @graphql-tools/delegate@10.0.5

Don't miss a new graphql-tools release

NewReleases is sending notifications on new releases.