4

I'm wondering what would be a nice solution to filter GraphQL queries by the current timestamp, e.g:

query {
  appointments(createdAt: today) { }
}

or

query {
  appointments(createdAt_gte: now) { }
}

Is it recommended to create my own resolver functions here? How would they look like, when e.g. graph.cool is used as a backend?

I don't want to rely on the correct time of the client but use the server time instead.

sinned
  • 698
  • 1
  • 7
  • 17
  • I would say: Use a service, get the server time and write your own resolver to compare the date. – Enayat Feb 14 '18 at 17:15

1 Answers1

1

If you don't want to rely on the client side for the date, you can send a paramater on your query i.e.

query {
  appointments(latestsOnly: true) { }
}

and resolve that paramater to the current date in the backend

Uziel Valdez
  • 2,040
  • 1
  • 15
  • 20