Unable to test Fulfillment Constraint

I am running into an issue when trying to test the Fulfillment Constraints function.

I keep getting this error from the Shopify GraphQL Admin app, however I have the scope deployed, linked to the .toml, and I have accepted the prompt to update the access scopes within my development store.

Here is my mutation:

mutation fulfillmentConstraintRuleCreate($deliveryMethodTypes: [DeliveryMethodType!]!, $functionId: String!, $metafields: [MetafieldInput!]) {
  fulfillmentConstraintRuleCreate(deliveryMethodTypes: $deliveryMethodTypes, functionId: $functionId, metafields: $metafields) {
    fulfillmentConstraintRule {
      function {
        id
      }
    }
    userErrors {
      field
      message
    }
  }
}

Variables

{
  "deliveryMethodTypes": ["SHIPPING"], 
  "functionId": "my-id-goes-here",
  "metafields": [
    {
      "namespace": "custom",
      "key": "pickup_from_store",
      "type": "boolean",
      "value": "false"
    }
  ]
}

Do I need to request access to this scope?

Please run the query to verify the currently granted access scopes

query {
  currentAppInstallation {
    accessScopes {
      description
      handle
    }
  }
}

Do you run the deploy command after making the app configuration changes?

Thank you. I do not see the scope within the store. I will try to reinstall the app again. This didn’t work before.

I tried to uninstall, and re-install and it did not work. I even built and deployed a Delivery Customization function to see if it was something I am doing wrong, but I think there could be something wrong on the Shopify side. It is possible I did miss something.

Do you see the scope in the partner dashboard app settings?

Yes.

Have you opened the app up in the shopify admin? Sometimes you have to do that and then it propmts you to accept new permissions.

Yes

1 Like

Are you using graphQL admin app to run the mutation query? Some scopes aren’t available within the GraphiQL app.

Use a local GraphiQL instance. If you are developing an app using Shopify CLI, you can launch GraphiQL while running the dev command by tapping the g key. Shopify CLI’s GraphiQL instance connects as your app, so it has the same access scopes as your app, and it can access data owned by your app. It can’t access data owned by other apps.

2 Likes

Oh yeah you shouldn’t be running this from the graphiql admin app - it doesn’t have the same permissions your app has - when you do shopify app dev in the cli it gives you a url to open up an app-scoped graphql interface where you can test queries.

1 Like

@AMaL @kalen - That was it. Wow, I had no idea you could not use the GraphQL Admin App for this. That has been my default. THANK YOU!!!

1 Like

Hi @AMaL @kalen

Are there other options for creating this mutation?

Because local dev command via CLI only works with dev\sandbox stores => https://monosnap.com/file/9nhMJL2NaSpEArURXX7DyoCZWQ6YtZ
and does not work if store shopify+ => https://monosnap.com/file/ca5NHOY6UQkNJUdQtc0Iu5TzwWHPJW

What are the options for triggering this mutation to create a mutation in an existing store on Shopify+?

I tried some things, but nothing worked for me:

  • through a tunnel with a connection to this app
  • by creating a token (in this case we do not see the functions that are available in our store)

I forget how I added it to the production website.

I have a custom app and I also have access to manage the store, so I can install my custom app on the production store however it needs to be hosted. Render has free hosting for shopify remix apps.

I think I added in a button click to the UI and had a mutation run onClick which allowed me to add it to the store.

There might be another way to do this, just not sure.

I also saw today that this guy created a graphql chrome extension for Shopify. Not sure it will work but you could try it out: https://chromewebstore.google.com/detail/shopify-graphql-api-clien/hlcdgpmjfephdfcopjekdmcbcmmabcge

1 Like