neo4j / neo4j-go-driver

Neo4j Bolt Driver for Go
Apache License 2.0
496 stars 70 forks source link

Add `GqlStatusObject` support as notifications to `ResultSummary` #588

Closed StephenCathcart closed 4 months ago

StephenCathcart commented 4 months ago

⚠️ This API is released as preview.

Introduces GQL-compliant status objects to the ResultSummary.

GqlStatusObject is a GQL-compliant Notification object and status of query execution, this new object includes GqlStatus and StatusDescription.

ResultSummary.GqlStatusObjects() always contains at least 1 status representing the Success, No Data or Omitted Result.

The GqlStatusObjects will be presented in the following order:

Migration from Notification

Most properties in Notification exist in the new GqlStatusObject, except Code and Title. The GqlStatusObject.GqlStatus is equivalent to Code in Notification, but with values compliant with GQL. The properties GqlStatusObject.Classification and GqlStatusObject.RawClassification are equivalent to Notification.Category and Notification.RawCategory. The name change is needed because Category has a different meaning in GQL.

Usage

Disabling GqlStatusObjects can be done in the same way as disabling Notifications. However, non-notification status can not be filtered (such as Success or No Data):

neo4j.NewDriverWithContext("neo4j://localhost", neo4j.BasicAuth("neo4j", "password", ""), func(config *config.Config) {
    config.NotificationsDisabledClassifications = notifications.DisableClassifications(notifications.Deprecation, notifications.Performance)
})

Iterating through GqlStatusObjects is also done in the same way as Notifications:

gqlStatusObjects := result.Summary.GqlStatusObjects()
for _, gqlStatusObject := range gqlStatusObjects {
    fmt.Printf(gqlStatusObject.GqlStatus())
    fmt.Printf(gqlStatusObject.StatusDescription())
    fmt.Printf(gqlStatusObject.DiagnosticRecord())
    // and so on
}

Deprecations

StephenCathcart commented 4 months ago

[Go] GQL Notifications Implementation to ADR

StephenCathcart commented 4 months ago

[Go] Add description to statuses