Shopify / tokengating-example-app

A Shopify example app that creates and enforces tokengated product discounts, written in Node.js
MIT License
35 stars 15 forks source link

Liquid gate object not populated anymore. API unstable? #4

Closed h4gen closed 1 year ago

h4gen commented 1 year ago

Hi,

I was playing around with the example and it worked fine so far. However, suddenly the gate object in Liquid is not populated anymore but the product.gated? property returns true. The queries for the creation of gate and gateSubject run without any errors and afaik I changed nothing there.

One interesting aspect is, that the response from mutation createGateSubject differs for me from the api docs. It should look like:

{
  "gateSubjectCreate": {
    "userErrors": [],
    "gateSubject": {
      "id": "gid://shopify/GateSubject/974631534",
      "configuration": {
        "id": "gid://shopify/GateConfiguration/43548663"
      },
      "active": false,
      "createdAt": "2023-01-20T10:22:35Z",
      "updatedAt": "2023-01-20T10:22:35Z"
    }
  }
}

but I get:

{
    gateSubjectCreate: {
        gateSubject: {
        id: 'gid://shopify/GateSubject/1048886',
        configuration: [Object],
           createdAt: '2023-02-22T17:13:11Z',
           updatedAt: '2023-02-22T17:13:11Z'
         },
         userErrors: []
}

So there seems no active attribute anymore. Also I find it very confusing that the subject holds no more reference to the product even though its part of the input. Does somebody know what the problem is? Or is it just because the API is unstable? Where can I get help?

Thanks, Hagen

michaelsunglee commented 1 year ago

👋 Hello @h4gen, thanks for reaching out!

Where can I get help?

You're asking in the right place, happy to answer these issues/questions

One interesting aspect is, that the response from mutation createGateSubject differs for me from the api docs.

Is your mutation the same as the example? These responses will differ based on the fields in your GraphQL query/mutation. For example, in your mutation if you don't ask for active, you won't receive it.

Minimal response example

mutation gateSubjectCreate($input: GateSubjectCreateInput!) {
  gateSubjectCreate(input: $input) {
    userErrors {
      field
      message
    }
    gateSubject {
      id
    }
  }
}

Also I find it very confusing that the subject holds no more reference to the product even though its part of the input

Appreciate the feedback here, we anticipate that a lot of the reading of gate subjects will be through the HasGates interface on the product, where you can query any attached gates. The query would look something like:

query gate {
  products(first: 10) {
    edges {
      node {
        id
        gates {
          id
          configuration {
            # query your metafield here
          }
        }
      }
    }
  }
}

However, suddenly the gate object in Liquid is not populated anymore but the product.gated? property returns true.

Could you share any relevant code here to help investigate? Is this still happening? Also want to sanity check that you have emailed us to enable this beta and are using the same shop to make this liquid call

h4gen commented 1 year ago

Hi @michaelsunglee 👋

Thank you for your swift reply. I actually figured it out. My theme app extension was just referencing the wrong namespace on the gate object which lead to an empty gate 😵‍💫 . Sorry for the hassle. I have another question, but I will open an new Issue for it.

Thanks, Hagen