Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add missing events to dialog subscription #1163

Merged
merged 2 commits into from
Sep 20, 2024

Conversation

oskogstad
Copy link
Collaborator

@oskogstad oskogstad commented Sep 20, 2024

Description

The DialogUpdated GraphQL subscription is not triggered when an activity is added, or when the dialog is deleted

  • Rename subscription to "dialogEvents"
  • Add type field, values are "DialogUpdated" and "DialogDeleted"

Related Issue(s)

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)

Documentation

  • Documentation is updated (either in docs-directory, Altinnpedia or a separate linked PR in altinn-studio-docs., if applicable)

Summary by CodeRabbit

  • New Features

    • Introduced a new DialogEventPayload structure to handle dialog events, including updates and deletions.
    • Updated subscriptions to reflect the new event handling mechanism.
  • Bug Fixes

    • Renamed and expanded dialog event handling to improve clarity and functionality.
  • Chores

    • Renamed constants for event topics to better represent the scope of dialog events.
  • Tests

    • Minor adjustments in architecture tests for internal class visibility.

Copy link
Contributor

coderabbitai bot commented Sep 20, 2024

Warning

Rate limit exceeded

@oskogstad has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 10 minutes and 57 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between a7af237 and ac4d6cb.

Walkthrough

Walkthrough

The pull request introduces significant modifications to the GraphQL schema and related classes for handling dialog events. The DialogUpdatedPayload type has been renamed to DialogEventPayload, and a new enum DialogEventType has been created to categorize dialog events as either updated or deleted. The subscription mechanism has been updated to reflect these changes, with a new subscription method for dialog events. Additionally, the handling of domain events has been standardized to use the new payload structure, enhancing the overall event processing within the application.

Changes

Files Change Summary
docs/schema/V1/schema.verified.graphql Renamed DialogUpdatedPayload to DialogEventPayload, added type: DialogEventType!, updated dialogUpdated subscription to dialogEvents, and introduced DialogEventType enum with values DIALOG_UPDATED and DIALOG_DELETED.
src/Digdir.Domain.Dialogporten.GraphQL/EndUser/DialogById/ObjectTypes.cs Renamed DialogUpdatedPayload to DialogEventPayload, added public DialogEventType Type { get; set; }, and introduced DialogEventType enum with members DialogUpdated = 1 and DialogDeleted = 2.
src/Digdir.Domain.Dialogporten.GraphQL/EndUser/DialogById/Subscriptions.cs Renamed method DialogUpdated to DialogEvents, updated parameters and return type to use DialogEventPayload, and modified logging behavior.
src/Digdir.Domain.Dialogporten.Infrastructure/DomainEvents/Outbox/ConvertDomainEventsToOutboxMessagesInterceptor.cs Updated event handling logic to send messages to Constants.DialogEventsTopic, modified payload structure to use DialogEventPayload, and added handling for DialogActivityCreatedDomainEvent.
src/Digdir.Domain.Dialogporten.Infrastructure/GraphQL/DialogEventPayload.cs Introduced new file defining DialogEventPayload struct with properties Id and Type, and added DialogEventType enum.
src/Digdir.Domain.Dialogporten.Infrastructure/GraphQL/GraphQlSubscriptionConstants.cs Renamed constant DialogUpdatedTopic to DialogEventsTopic and updated its value.
tests/Digdir.Domain.Dialogporten.Architecture.Tests/InfrastructureArchitectureTests.cs Removed a blank line between entries in the All_Classes_In_Infrastructure_Should_Be_Internal method.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@oskogstad oskogstad changed the title [DRAFT] fix: Add missing events to dialog subscription fix: Add missing events to dialog subscription Sep 20, 2024
@oskogstad oskogstad marked this pull request as ready for review September 20, 2024 08:58
@oskogstad oskogstad requested a review from a team as a code owner September 20, 2024 08:58
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between a91706f and a7af237.

Files selected for processing (7)
  • docs/schema/V1/schema.verified.graphql (4 hunks)
  • src/Digdir.Domain.Dialogporten.GraphQL/EndUser/DialogById/ObjectTypes.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.GraphQL/EndUser/DialogById/Subscriptions.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Infrastructure/DomainEvents/Outbox/ConvertDomainEventsToOutboxMessagesInterceptor.cs (2 hunks)
  • src/Digdir.Domain.Dialogporten.Infrastructure/GraphQL/DialogEventPayload.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Infrastructure/GraphQL/GraphQlSubscriptionConstants.cs (1 hunks)
  • tests/Digdir.Domain.Dialogporten.Architecture.Tests/InfrastructureArchitectureTests.cs (1 hunks)
Additional comments not posted (13)
src/Digdir.Domain.Dialogporten.Infrastructure/GraphQL/GraphQlSubscriptionConstants.cs (1)

6-6: Verify the impact on the GraphQL schema and subscription mechanism.

The constant renaming and value change align with the PR objective of renaming the subscription to "dialogEvents" and introducing a new type field. This change indicates a broader scope of events related to dialogs rather than just updates.

Please ensure that the GraphQL schema and subscription mechanism have been updated to reflect this change. Run the following script to verify:

Verification successful

Changes to GraphQL schema and subscription mechanism verified

The renaming from DialogUpdatedTopic to DialogEventsTopic has been successfully implemented across the codebase. The GraphQL schema (docs/schema/V1/schema.verified.graphql) has been updated to include the dialogEvents subscription and DialogEventPayload type. The C# implementation in Subscriptions.cs correctly uses the new DialogEventsTopic constant, which is defined in GraphQlSubscriptionConstants.cs.

Key points:

  • GraphQL schema includes dialogEvents subscription and DialogEventPayload type
  • C# implementation uses the new DialogEventsTopic constant
  • No remnants of the old "DialogUpdated" naming found in the codebase

The changes are consistent and align with the PR objective of renaming the subscription to "dialogEvents" and introducing a new type field.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the GraphQL schema and subscription mechanism have been updated.

# Test 1: Search for the old constant usage. Expect: No occurrences.
rg --type csharp -i $'DialogUpdatedTopic'

# Test 2: Search for the new constant usage. Expect: Occurrences in relevant files.
rg --type csharp -i $'DialogEventsTopic'

# Test 3: Search for the GraphQL subscription. Expect: Subscription renamed to "dialogEvents".
rg --type graphql -i $'subscription DialogUpdated'

# Test 4: Search for the GraphQL payload type. Expect: Payload type renamed to "DialogEventPayload".
rg --type graphql -i $'type DialogUpdatedPayload'

Length of output: 1172


Script:

#!/bin/bash
# Description: Verify GraphQL schema and subscription mechanism updates without relying on 'graphql' file type

# Test 1: Search for GraphQL subscription definition
rg -i 'subscription\s+DialogUpdated'

# Test 2: Search for GraphQL subscription definition with new name
rg -i 'subscription\s+DialogEvents'

# Test 3: Search for old payload type
rg -i 'type\s+DialogUpdatedPayload'

# Test 4: Search for new payload type
rg -i 'type\s+DialogEventPayload'

# Test 5: Find potential GraphQL schema files
fd -e graphql -e gql

# Test 6: If no .graphql or .gql files found, search for GraphQL schema definition in code
rg 'ISchema|GraphQLSchema|buildSchema|makeExecutableSchema'

Length of output: 533


Script:

#!/bin/bash
# Description: Inspect GraphQL schema file and search for subscription-related content

# Test 1: Display the contents of the GraphQL schema file
cat docs/schema/V1/schema.verified.graphql

# Test 2: Search for any subscription-related content in the codebase
rg -i 'subscription\s+\w+' --type cs

# Test 3: Search for DialogEvents in the codebase (case-insensitive)
rg -i 'DialogEvents' --type cs

Length of output: 10247

src/Digdir.Domain.Dialogporten.Infrastructure/GraphQL/DialogEventPayload.cs (2)

3-7: LGTM!

The DialogEventPayload struct provides a clean and standardized structure for representing dialog event payloads. The properties are well-defined and the internal access modifier ensures proper encapsulation.


9-13: LGTM!

The DialogEventType enum provides a clear and extensible categorization of dialog events. The explicit integer values assigned to the enum members is a good practice. The internal access modifier ensures proper encapsulation.

src/Digdir.Domain.Dialogporten.GraphQL/EndUser/DialogById/Subscriptions.cs (2)

13-15: LGTM!

The changes to the subscription method align well with the objective to handle both dialog updated and deleted events. Using a separate constant for the topic and changing the parameter type to DialogEventPayload improves maintainability and allows passing more information about the event.


19-19: LGTM!

Directly returning the eventMessage aligns with the updated method signature and the usage of DialogEventPayload. This change looks good.

tests/Digdir.Domain.Dialogporten.Architecture.Tests/InfrastructureArchitectureTests.cs (1)

18-18: LGTM!

The removal of the blank line is a cosmetic change and does not affect the logic of the test.

src/Digdir.Domain.Dialogporten.GraphQL/EndUser/DialogById/ObjectTypes.cs (2)

204-208: LGTM! Remember to update the code that uses this class.

The changes to the DialogEventPayload class, including the class name change and the addition of the Type property, improve the design and functionality of the dialog event system. These changes allow the payload to represent and categorize different types of dialog events, not just updates.

Please ensure that the code that uses this class is updated to reflect these changes.


210-213: Looks good!

The DialogEventType enum is a valuable addition to the codebase. It provides a clear way to categorize dialog events into updates and deletions, which enhances the overall functionality of the dialog event system. The enum members are well-named and have appropriate numeric values.

The usage of this enum in the DialogEventPayload class ensures that the payload can effectively specify the type of event.

docs/schema/V1/schema.verified.graphql (4)

135-137: Breaking change: Renamed DialogUpdatedPayload to DialogEventPayload and added type field.

The changes look good! Renaming the payload to DialogEventPayload and introducing the type field allows for capturing a broader range of dialog events, including updates and deletions. This aligns well with the PR objective.

Note that this is a breaking change for existing clients. They will need to update their subscription query to use the new payload name and handle the new type field.


215-215: Breaking change: Renamed dialogUpdated subscription to dialogEvents.

The subscription renaming aligns perfectly with the new DialogEventPayload and the goal of supporting additional event types. Nicely done!

Just keep in mind that existing clients will need to update their subscription query to use the new dialogEvents name and handle the new DialogEventPayload format.


300-303: New feature: Added DialogEventType enum.

The new DialogEventType enum is a great addition! It provides a clear and structured way to categorize dialog events into updates and deletions.

Clients will need to handle both the DIALOG_UPDATED and DIALOG_DELETED cases when consuming the dialogEvents subscription, but that's expected given the expanded scope of the subscription.


364-364: New feature: Added UUID scalar.

Adding the UUID scalar is a nice touch! It provides a standard and validated way to represent UUIDs throughout the schema.

Specifying the scalar with the RFC 4122 URL is perfect, as it clearly communicates the expected format and links to the official specification.

src/Digdir.Domain.Dialogporten.Infrastructure/DomainEvents/Outbox/ConvertDomainEventsToOutboxMessagesInterceptor.cs (1)

93-98: Verify the event type for DialogActivityCreatedDomainEvent

In the DialogActivityCreatedDomainEvent case, the Type is set to DialogEventType.DialogUpdated. Please verify if using DialogEventType.DialogUpdated here accurately represents the event, or if a new event type should be introduced to differentiate dialog activity creations.

Copy link

@oskogstad oskogstad merged commit 162ce9a into main Sep 20, 2024
21 checks passed
@oskogstad oskogstad deleted the fix/add-missing-events-to-subscription-stream branch September 20, 2024 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants