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

feat: add GraphQL to fetch notifications #68

Merged
merged 3 commits into from
Nov 29, 2023

Conversation

PrinceYadav2
Copy link
Contributor

@PrinceYadav2 PrinceYadav2 commented Nov 28, 2023

Description:
This PR adds graphql and to fetch all the notifications

Related changes:
Implement graphql for application root
Add a function to fetch all the notifications
Add Notification Resolver
Register Returning Models by modifying notification entity.

Curl:


curl 'http://localhost:3000/graphql' -H 'Accept-Encoding: gzip, deflate, br' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Connection: keep-alive' -H 'DNT: 1' -H 'Origin: http://localhost:3000' -H 'Authorization: Bearer <SERVER_AUTH_TOKEN>' --data-binary '{"query":"query {\n  notifications {\n    channelType\n    createdBy\n    createdOn\n    data\n    deliveryStatus\n    id\n    result\n    status\n    updatedBy\n  }\n}"}' --compressed

Sample Response:

{
  "data": {
    "notifications": [
      {
        "channelType": 2,
        "createdBy": "osmo_notify",
        "createdOn": "2023-11-28T04:59:32.000Z",
        "data": {
          "from": "[email protected]",
          "to": "[email protected]",
          "subject": "Test subject",
          "text": "This is a test notification",
          "html": "<b>This is a test notification</b>"
        },
        "deliveryStatus": 3,
        "id": 1,
        "result": {
          "result": {
            "status": 200,
            "id": "<[email protected]>",
            "message": "Queued. Thank you."
          }
        },
        "status": 1,
        "updatedBy": "osmo_notify"
      },
      {
        "channelType": 1,
        "createdBy": "osmo_notify",
        "createdOn": "2023-11-28T05:04:30.000Z",
        "data": {
          "from": "[email protected]",
          "to": "[email protected]",
          "subject": "Test subject",
          "text": "This is a test notification",
          "html": "<b>This is a test notification</b>"
        },
        "deliveryStatus": 4,
        "id": 2,
        "result": {
          "result": {
            "errno": -3008,
            "code": "EDNS",
            "syscall": "getaddrinfo",
            "hostname": "smtp.gmail.com",
            "command": "CONN"
          }
        },
        "status": 1,
        "updatedBy": "osmo_notify"
      }
    ]
  }
}

Snapshot:
Success:
image
Fail:
image

@xixas xixas changed the title feat: Add GraphQL to fetch notifications feat: add GraphQL to fetch notifications Nov 28, 2023
@xixas
Copy link
Collaborator

xixas commented Nov 28, 2023

@PrinceYadav2
Copy link
Contributor Author

@PrinceYadav2 We have recently also added API key guard. Add this for graphQL too

https://github.com/OsmosysSoftware/osmo-notify/blob/7778edb226a7fa83e0bf0fa360a4760278fc8bde/src/modules/notifications/notifications.controller.ts#L26

Added API key guard for the same, attached a screenshot of failing case in description.

@PrinceYadav2 PrinceYadav2 force-pushed the feature/add-graphql-for-notificatons branch from 6fe2cce to 529d4ae Compare November 29, 2023 07:51
@osm-vishnukyatannawar osm-vishnukyatannawar merged commit fee3bd8 into main Nov 29, 2023
8 checks passed
@osm-vishnukyatannawar osm-vishnukyatannawar deleted the feature/add-graphql-for-notificatons branch November 29, 2023 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants