Gift card expiration behavior between graphql vs rest api

We’re looking at migrating some gift card functionality from the rest api to the graphql api, and running into a seemingly undocumented difference in behaviors between the two.

We want to be able to create gift cards which honor the stores’s global gift card expiration setting as specified here:

When creating gift cards via the rest api, if an explicit expiration date is not set, then the created resource has an expiration as defined by that global setting.

When using the graphql api to create gift cards, if an expiresOn is not set, then the gift card never expires.

This seems to simply be a gap in functionality between the two api’s, and we’re a bit stumped at how to migrate over without losing this capability.

The obvious fallback will be to simply require the users to specify that same global setting in our application as well, but this is awkward at best, and opens up to drift between these settings over time (with no way for us to subscribe to updates to that setting either).

Any ideas?

1 Like

Hey @atreidesend - I was able to replicate this. I’m going to look into this on our end to see what the best next steps we have are. Loop back with you here once I have more info

1 Like

nice, thanks for picking it up!

Hey @atreidesend - no worries! This is on our radar now. Generally, the GraphQL and REST API don’t have exactly the same behaviour everywhere, but what you’re seeing in REST is actually a good use case for GraphQL, so we’re looking into enabling this. I can’t guarantee anything other than it’s been flagged to our team, but I’ll update you once I have more to share here.

Hey @atreidesend - we’ve pushed a change that should help with this. A nullvalue for Gift Card expiration still won’t automatically default to the store’s default config, but you can now programatically grab that info like this:

query { 
  giftCardConfiguration {
    expirationConfiguration {
      expirationUnit
      expirationValue
    }
  }
}

This should be live in the unstable version of the API. Can you let me know if this works for you? Not the most ideal solution there, but you could run a job whenever your app is installed on a shop that pulls the expiration config and just blanket applies it to all gift cards being created going forward. Hope this helps!

1 Like

Thanks, yeah this is at least something we can use to get close. Appreciate the quick turnaround!

No worries @atreidesend, I’ll close out the thread for now, but we did publish some release notes for it. Just wanted to share in case it’s helpful for reference: