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 search support to graphQl query #118

Merged
merged 7 commits into from
Jan 17, 2024

Conversation

xixas
Copy link
Collaborator

@xixas xixas commented Jan 16, 2024

  • Added Options which supports Searching.
  • Had to update service to use Query Builder due to limitation in earlier code.
  1. Use the graphQL playground to test.

Request Query:

query {
  combinedFilters: notifications(options: {
    limit: 2,
    offset: 0,
    sortBy: "createdOn",
    sortOrder: DESC,
    search: "jacuzisplot",
    filters: [
      { field: "channelType", operator: "eq", value: "1" },
      { field: "createdOn", operator: "lt", value: "2024-01-01T00:00:00.000Z" }
    ]
  }) {
    notifications {
      id
      channelType
      createdBy
      createdOn
      data
    }
    total
  }
}

Or in postman
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' --data-binary '{"query":"query {\n  combinedFilters: notifications(options: {\n    limit: 2,\n    offset: 0,\n    sortBy: \"createdOn\",\n    sortOrder: DESC,\n    search: \"jacuzisplot\",\n    filters: [\n      { field: \"channelType\", operator: \"eq\", value: \"1\" },\n      { field: \"createdOn\", operator: \"lt\", value: \"2024-01-01T00:00:00.000Z\" }\n    ]\n  }) {\n    notifications {\n      id\n      channelType\n      createdBy\n      createdOn\n      data\n    }\n    total\n  }\n}\n"}' --compressed

Response

{
  "data": {
    "filterById": {
      "notifications": [
        {
          "id": 50,
          "channelType": 3,
          "createdBy": "admin",
          "createdOn": "2023-11-03T07:34:55.000Z"
        }
      ],
      "total": 1
    },
    "filterByChannelType": {
      "notifications": [
        {
          "id": 48,
          "channelType": 2,
          "createdBy": "admin",
          "createdOn": "2023-11-03T07:34:53.000Z"
        }
      ],
      "total": 23
    },
    "filterByCreatedDate": {
      "notifications": [
        {
          "id": 48,
          "channelType": 2,
          "createdBy": "admin",
          "createdOn": "2023-11-03T07:34:53.000Z"
        }
      ],
      "total": 97
    },
    "combinedFilters": {
      "notifications": [
        {
          "id": 58,
          "channelType": 1,
          "createdBy": "admin",
          "createdOn": "2023-11-03T12:50:59.000Z"
        }
      ],
      "total": 39
    }
  }
}

@osm-vishnukyatannawar osm-vishnukyatannawar merged commit 134bbf5 into main Jan 17, 2024
8 checks passed
@osm-vishnukyatannawar osm-vishnukyatannawar deleted the feat/notification-search branch January 17, 2024 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants