MyGit

v3.3.0

graphql-python/graphene

版本发布时间: 2023-07-26 14:47:55

graphql-python/graphene最新发布版本:v3.3.0(2023-07-26 14:47:55)

This release brings two new features and several fixes and semantic upgrades due to new Python features. Thanks to everyone that contributed! 😊

Default value for InputObjectTypes

⚠️⚠️ACTION REQUIRED⚠️⚠️ In GraphQL, inputs can have fields which are optional. Currently, if those fields are not specified in the query, they are passed to the python inputs as None. This renders them indistinguishable from fields that are actually passed to the query with a value of null. While the alternative would be to check the definition via "key" in input, it is more accessible to mark these fields as explicitly UNDEFINED. This PR adds a new global override, which allows unspecified fields to be set to graphql.UNDEFINED. In the future, the default Value will be set to UNDEFINED, making this a soft migration and deprecation of the previous situation.

This is a soft migration. Long-Term, the Input Objects will ALWAYS contain the value UNDEFINED Make sure your code supports these cases in None checks. After the default has been set to UNDEFINED, you will still be able to switch back to None for the foreseeable future.

Strict connection types support in Relay

Custom Relay connection classes can now be made NonNull using the strict_types option on the connection meta.

Using this example

  class MyObjectConnection(Connection):
      class Meta:
          node = MyObject
          strict_types = True

will change from

type MyObjectConnection {
   edges: [MyObjectEdge]
}

to

type MyObjectConnection {
   edges: [MyObjectEdge!]!
}

Caveats

We want to make sure you're informed about using NonNull relay connections. While they are a great way to get rid of some null checks in typed frontends, it's important to be mindful of error handling with these connections. When working with NonNull connections, it's crucial to remember that if a requested field or edge is not available or the resolver throws an error, the error will bubble up to the next nullable parent field, which is oftentimes the root node. That way, you cannot handle partial results in case of partial errors anymore. In a nullable connection, only the nullable fields will be set to null and the error will not bubble up.

To address this, we recommend considering waiting for the future release of client-controlled nullability for cases where certain connections might be nullable. By opting for client-controlled nullability, you gain more control over error handling, enabling you to handle potential null values more gracefully and enhance the overall user experience. Read more about client controlled nullability here: https://github.com/graphql/graphql-spec/issues/867

What's Changed

New Contributors

Full Changelog: https://github.com/graphql-python/graphene/compare/v3.2.2...v3.3.0

相关地址:原始地址 下载(tar) 下载(zip)

查看:2023-07-26发行的版本