isFuture based on midnight?

Hello,

I'm modelling a collection that lists events. I'm using the isFuture filter to list events with a date in the future.

query servicespageQuery {
    
    allPrismicService(
      filter: { data: { isFuture: { eq: true } } }
      sort: { order: ASC, fields: data___date }
      limit: 10
    ) {

I come to a sticking point which how I think this parameter works, presumably it uses the date and midnight as the time is is checking, so an event on say 1st December 2022 is only in the future until 1st Dec 2022 00:00 - so for the rest of that day it isn't, which in an event listing you would really want it to be in the future still so that it is listed on the site on the day of the event.

Is there a way to change when the isFuture parameter works? Or something I am not understanding?

Hello @webdev2, isFuture is a boolean field in your documents. This means that whoever edits the document can modify these values and assign a true or false value related to a date field even if it's accurate or not.

I don't really understand what you mean here Pau.

The isFuture is built in to the prismic collection and not a field I have added myself to the collection


It is an inbuilt filter - I would like to understand how it works as currently its not fit for my use case or any I can see that would be useful.

But it maybe that I'm misunderstanding it.

The fields inside the filter > data argument are existing fields inside your Custom Type. Can you send me the URL of your repository so I can run a test on my end?

of course https://actorschurch.prismic.io/

I just ran a test on your repository's GraphiQL explorer. There's no isFuture field available in the schema. Is it possible that you've made recent changes to the Custom Types?

Hi Pau, isFuture is not something I have added, I am leveraging it as a filter that I presume is being added because there is a timestamp field. It appears to be inbuilt.

It is working on an events page in the front end, so can't be something I have deleted

This page uses it:-

Just isn't working as I expected, it is using the first minute of the day as the cutoff.

I'm thinking of changing the date field to date and time so presumably the internal would use that as its using timestamps presumably internally?

Can you try and open your project in development. Paste this same query in the playground, run the query and see what it retrieves?
It's important to double-check these kinds of attributes work in the queries before adding them to your project.

Hi Pau,

It works, just not as expected - which is what I say in the first message

Here is response:-

query alleventsQuery {
      allPrismicEvent(
        filter: { data: { isFuture: { eq: true } } }
        sort: { order: ASC, fields: data___end_date }
      ) {
        edges {
          node {
            id
            data {
              title {
                raw
              }
              blurb {
                raw
              }
              end_date
              isFuture
             
              readable_end_date: end_date(formatString: "D MMMM YYYY")
              readable_start_date: start_date(formatString: "D MMMM YYYY")
              readable_end_day: end_date(formatString: "Do")
              readable_end_month: end_date(formatString: "MMM")
              readable_start_day: start_date(formatString: "Do")
              readable_start_month: start_date(formatString: "MMM")
              start_date
             
            }
            tags
            uid
            url
          }
        }
      }
    }

Here is the result

{
  "data": {
    "allPrismicEvent": {
      "edges": [
        {
          "node": {
            "id": "cba31020-f763-5d37-97b6-1556343a7f62",
            "data": {
              "title": {
                "raw": [
                  {
                    "type": "heading1",
                    "text": "Valhalla High School Choir",
                    "spans": []
                  }
                ]
              },
              "blurb": {
                "raw": [
                  {
                    "type": "paragraph",
                    "text": "The Actor's Church welcomes Valhalla High School on their global tour for a free lunchtime concert.",
                    "spans": []
                  }
                ]
              },
              "end_date": "2022-03-22",
              "isFuture": true,
              "readable_end_date": "22 March 2022",
              "readable_start_date": "22 March 2022",
              "readable_end_day": "22nd",
              "readable_end_month": "Mar",
              "readable_start_day": "22nd",
              "readable_start_month": "Mar",
              "start_date": "2022-03-22"
            },
            "tags": [],
            "uid": "valhalla-choir",
            "url": "/"
          }
        },
        {
          "node": {
            "id": "1cfafbd9-ecbe-5b50-a22b-d6adde9eddc1",
            "data": {
              "title": {
                "raw": [
                  {
                    "type": "heading1",
                    "text": "Baby Gospel - Family Concert",
                    "spans": []
                  }
                ]
              },
              "blurb": {
                "raw": [
                  {
                    "type": "paragraph",
                    "text": "The Actors' Church is delighted to welcome back Baby Gospel. A concert for the whole family, with hits by Marvin Gaye, Bob Marley, Adele, Jackie Wilson, Pharrell and more.",
                    "spans": []
                  }
                ]
              },
              "end_date": "2022-03-23",
              "isFuture": true,
              "readable_end_date": "23 March 2022",
              "readable_start_date": "23 March 2022",
              "readable_end_day": "23rd",
              "readable_end_month": "Mar",
              "readable_start_day": "23rd",
              "readable_start_month": "Mar",
              "start_date": "2022-03-23"
            },
            "tags": [
              "concert"
            ],
            "uid": "1100am",
            "url": "/"
          }
        },
        {
          "node": {
            "id": "16cb0f44-fb01-515a-a2f2-af4695b6b403",
            "data": {
              "title": {
                "raw": [
                  {
                    "type": "heading1",
                    "text": "Artaban the Musical",
                    "spans": []
                  }
                ]
              },
              "blurb": {
                "raw": [
                  {
                    "type": "paragraph",
                    "text": "The New Rock Musical filled with Heart and Soul, an uplifting story follows the adventures of Artaban the 4th Wise Man on his lifelong quest to deliver his gift of gemstones to Jesus. Will he succeed?",
                    "spans": []
                  }
                ]
              },
              "end_date": "2022-03-31",
              "isFuture": true,
              "readable_end_date": "31 March 2022",
              "readable_start_date": "31 March 2022",
              "readable_end_day": "31st",
              "readable_end_month": "Mar",
              "readable_start_day": "31st",
              "readable_start_month": "Mar",
              "start_date": "2022-03-31"
            },
            "tags": [
              "performance",
              "iris"
            ],
            "uid": "artaban-the-musical",
            "url": "/"
          }
        },
        {
          "node": {
            "id": "a33abba7-9393-5ffd-805d-5a30db74960e",
            "data": {
              "title": {
                "raw": [
                  {
                    "type": "heading1",
                    "text": "Platform - Jack Miles & Friends",
                    "spans": []
                  }
                ]
              },
              "blurb": {
                "raw": [
                  {
                    "type": "paragraph",
                    "text": "PLATFORM artist Jack Miles will take to the stage, alongside an multi-award winning cast, for a one-night-only concert celebrating his work as one of the country's most exciting contemporary musical theatre composers.",
                    "spans": []
                  }
                ]
              },
              "end_date": "2022-04-08",
              "isFuture": true,
              "readable_end_date": "8 April 2022",
              "readable_start_date": "8 April 2022",
              "readable_end_day": "8th",
              "readable_end_month": "Apr",
              "readable_start_day": "8th",
              "readable_start_month": "Apr",
              "start_date": "2022-04-08"
            },
            "tags": [
              "concert"
            ],
            "uid": "platform---jack-miles--friends",
            "url": "/"
          }
        }
      ]
    }
  },
  "extensions": {}
}

That's really odd. I ran a test using your endpoint and every content field is there except for this one.

Can you please show me a screenshot of the filter options in the schema, in the documentation explorer?

Hey @webdev2. I consulted this with my team. One of my colleagues pointed out that, if it isn't a boolean field, then is possible that someone else on your team used Gatsby’s schema customization APIs. It lets you add custom fields to nodes, just like the source plugin gatsby-source-prismic does.

Here's a similar code snippet on GitHub

Nope. Solo developer. I know the codebase, there is no customisation.

It appears to inbuilt in your product.

I can try and set up something else and see if it appears if you like

Is it part of your gatsby-source-plugin?

I understand. Did you start the project with a boilerplate outside of Prismic?
I'm not sure why you're getting that result if you didn't add it yourself. But, no this isn't something that's part of the source plugin.

Looking closer at this screenshot, there are other fields like id, internal, and parent in the data field that aren't part of the schema as well.

I'm pretty sure gatsby is adding these, I'm used to seeing them

I need to get this site launched, So I will come up with an alternative solution then come back to this and try and work out where isFuture comes from.

1 Like

Ok. Thanks for sharing!