Is there a way to determine the subcsription status of an app via the Shopify node client or in the GraphQL API?
Given a user has signed up to our public app, when they log in. then I should be able to check if their Shopify subscription to our app is still active.
I can see via the GraphQL API I can query
currentAppInstallation {
activeSubscriptions {
id
name
test
}
}
This seems to return an empty array, implying my test store I doesn't have any active subscriptions. This may be due to my app and shop being in test mode though.
Does anybody know if this is the case or is there another way to get the subscription status?
Also, it would be good to do via the Shopify client if that is possible?
This is how I did if I have the APP subscription ID, I got the GraphQL query from Shopify's Billing API documentation:
query {
node(id: "gid://shopify/AppSubscription/4019585080") {
...on AppSubscription {
billingInterval
createdAt
currentPeriodEnd
id
name
status
test
lineItems {
plan {
pricingDetails {
...on AppRecurringPricing {
interval
price {
amount
currencyCode
}
}
...on AppUsagePricing {
terms
cappedAmount {
amount
currencyCode
}
balanceUsed {
amount
currencyCode
}
}
}
}
}
}
}
}
Notice that status is defined at root, so you'll get it inside the node.
Related
Im having trouble with my Shopify Function where I want to give a discount on the products if the client chooses pickup. Is there a way to get if the client picked PICK_UP as the delivery option ? I tried looking into this option HERE, but the response from shopify comes back empty does not matter if I choose shipping option or a pickup option. Here is my input query:
query Input {
cart {
lines {
quantity
merchandise {
__typename
...on ProductVariant {
id
}
}
}
deliveryGroups {
selectedDeliveryOption {
deliveryMethodType
}
}
}
discountNode {
metafield(namespace: "this", key: "that") {
value
}
}
}
Am I doing anything wrong? Any ideas what I could try?
I need to fetch all products using Shopify API by collection id...
I tried:
mutation {
bulkOperationRunQuery(
query:"""
{
products(query: "tag:women OR collection:172173852808") {
edges{
node{
id
tags
images {
edges {
node {
id
originalSrc
}
}
}
variants(first:10) {
edges{
node{
id
price
compareAtPrice
image{
originalSrc
}
inventoryQuantity
selectedOptions{
name
value
}
sku
title
weight
weightUnit
}
}
}
}
}
}
}
"""
) {
bulkOperation {
id
status
}
userErrors {
field
message
}
}
}
Result Shopify gives me is just product with tags: women and there are no products from collection id 172173852808
How to run a query to get products from one or more specific connections?
If every product in that collection has the tag woman, just change your query to bulk download the collection and its products. Also, before you go and do a bulk query, verify it works without being a bulk query. That usually exposes the problems with the setup.
I am trying to load user information from GitLab so that I can associate usernames with issues. When querying for issues, the assignee username is not directly available. Instead, a user ID is available.
If I execute this GraphQL query using the /-/graphql-explorer endpoint on my GitLab deployment:
query {
users {
nodes {
id
name
username
}
}
}
then 91 users are returned. This is clearly not all users on the deployment, though. There are users I know exist but which are not included in the result. I can query for them individually using this GraphQL query:
query {
user(username: "someusername") {
id
}
}
and receive a result which seems to correctly describe the user.
Why are some users omitted from the results for this query? I know that large result sets require dealing with pagination but the default page size is supposed to be 100 and I am receiving fewer results than this. Additionally, if I request pageinfo and ask for the users after the resulting endCursor I receive no items.
How do I submit a query that gets me all users? Failing that, how do I submit a query that will get me all users which could be assignees for a a group (or, failing that, for a list of projects)?
From the documentation :
By default, GitLab’s GraphQL API will return only the first 100 records of any collection. This can be changed by using first or last arguments. Both arguments take a value, so first: 10 will return the first 10 records, and last: 10 the last 10 records.
So you have to do the pagination yourself, your first query would be for example :
query {
users(first: 10) {
edges {
node {
id
name
username
}
}
pageInfo {
endCursor
hasNextPage
}
}
}
Then use the PageInfo result values to know if you have more pages to fetch and the cursor ID to fetch the next page, for example you could get the following result :
...
"pageInfo": {
"endCursor": "eyJpZCI6Ijc****************zNjk0MDUwMDAgOVRDIn0",
"hasNextPage": true
}
So for the next page, you have to query :
query {
users(first: 10, after: "eyJpZCI6IjcxMj**********************Ni4zNjk0MDUwMDAgOVRDIn0") {
edges {
node {
id
name
username
}
}
pageInfo {
endCursor
hasNextPage
}
}
}
And so on until hasNextPage returns false.
For more info about pagination and cursors, see GraphQL documentation : https://graphql.org/learn/pagination/
I have a GraphQL query called myAccounts which returns an array of accounts. When I go to the Playground and call the query:
{
accounts {
email
}
}
I get this result:
"data": {
"accounts": [
{
"email": "zach#email-one.com",
},
{
"email": "zach#email-two.com",
}
]
}
However, when I am in my Component, vue-apollo returns two items in the array, but seems to overwrite the second item with the first. Here is the query (in MyAccounts.gql):
query myAccounts {
accounts: myAccounts {
email
}
}
and here is the Apollo query in the component:
import MY_ACCOUNTS_QUERY from '~/apollo/queries/MyAccounts'
...
apollo: {
accounts: {
query: MY_ACCOUNTS_QUERY,
result(data) {
console.log(JSON.stringify(data))
}
}
}
and here is what vue-apollo logs out through the result:
{
"data":{
"accounts":[
{
"email":"zach#email-one.com",
"__typename":"Account"
},
{
"email":"zach#email-one.com",
"__typename":"Account"
}
]
},
"loading":false,
"networkStatus":7,
"stale":false
}
Expected behavior
I would expect the data returned in the Playground to be identical to what vue-apollo is fetching.
Versions
vue: 2.6.10
vue-apollo: #nuxtjs/apollo: 4.0.0-rc18
Additional context
I thought the result hook would be the best way to debug, but any other suggestions gladly welcomed. I assumed that this was a bug in our code, but I cannot figure out what could be causing the repetition (and mismatch).
Apollo normalizes its cache based on the __typename and the id (or _id) field. You need to include an id or _id field in your selection set alongside email. Failing to do so results in both objects being assigned the same key. If you don't have an id field to request, you'll need to provide a custom dataIdFromObject function as shown here.
From Guillaume Chau (https://github.com/Akryum):
This is because the Apollo Client cache can't compute a different ID
for the two items, so you endup with Account:undefined (or similar)
for both. Open the Apollo devtools and look at the myAccounts key in
the cache.
Learn more:
https://www.apollographql.com/docs/react/caching/cache-configuration/
Is there a way to query reactions filtering on issue number and user?
{
repository(owner: "w3c", name: "webcomponents") {
issue(number: 688) {
title
reactions(last: 100) { <--- I want to filter on user here
edges {
node {
user {
login
}
content
id
}
}
}
}
}
}
https://developer.github.com/v4/explorer/
Not at the moment, but you can request this functionality by creating a new post here and tagging the post as a schema-request.
No, unfortunately github graphql api doesn't provide this capability to query reactions by known user in this context.