Skip to content
Compare
Choose a tag to compare
@lrlna lrlna released this 27 Aug 15:01
· 6 commits to main since this release
e651a95

Features

  • Add ignore_builtin_redefinitions method to SchemaBuilder- dariuszkuc, pull/990 and pull/994

    This allows input SDL to contain built-in types.

    The following SDL will result in a validation error, for example:

      let schema = r#"
        type __Directive {
          name: String!
          description: String!
          isRepeatable: String!
          args: __InputValue
          locations: String!
        }
        type Query {
          foo: String
        }
        "#;
    
      let valid = Schema::parse_and_validate(schema, "schema.graphql")?

    Error:

      Error: the type `__Directive` is defined multiple times in the schema
        ╭─[ built_in.graphql:87:6 ]
        │
     87 │ type __Directive {
        │      ─────┬─────  
        │           ╰─────── previous definition of `__Directive` here
        │
        ├─[ schema.graphql:2:6 ]
        │
      2 │ type __Directive {
        │      ─────┬─────  
        │           ╰─────── `__Directive` redefined here
        │ 
        │ Help: remove or rename one of the definitions, or use `extend`
    ────╯

    However, when using the ignore_builtin_redefinitions method, this successfully passes validation given the same schema:

      let builder = SchemaBuilder::new().ignore_builtin_redefinitions();
      let _ = builder
          .parse(schema, "schema.graphql")
          .build()
          .expect("schema parsed successfully");

Fixes

  • Fix handling of orphan root type extensions - dariuszkuc, pull/993

    SchemaBuilder's adopt_orphan_extensions method allows users to define type
    extensions without an existing type definition. But before this fix, orphan
    RootTypeOperation extensions would result in an invalid schema despite
    adopt_orphan_extensions being enabled. Using this method now generates a
    valid schema for all lone extensions.

  • Fix directive definition validation with nested types arguments - dariuszkuc, pull/987

    Directive definition with nested argument types resulted in a stack overflow, for example

      directive @custom(input: NestedInput) on OBJECT | INTERFACE
    
      input NestedInput {
        name: String
        nested: NestedInput
      }
      
      type Query @custom(input: {name: "hello", nested: {name: "hello"}}) {
        foo: String
      }
      
      query myQuery {
        foo
      }

    This fix ensures the above example is possible and does not result in a validation error.

  • Fix iter_origins() to be a pub method - duckki, pull/989

    Previously added ::iter_origins() methods on Schema and Type Definitions was not made pub.