Local vs. GraphiQL

I have been having an issue where a query that runs without issues on GraphiQL gives an error when executed locally. For instance, when querying media:
Local error

GraphiQL

The same thing also happens when I attempt to delete items – the destroyProjectMedia mutation causes a No permission to delete Dynamic error locally but not on GraphiQL.

The function I have been using to execute the query locally (and its helper) are below:

image

Is the discrepancy an issue with one of these functions or something else entirely?

Hi Vyoma,

I think there are two similar, but different problems:

1 - The query project(id: "3111")... only works correctly on GraphiQL

I tried locally and I could reproduce this, I’ll register the issue.
While this one is not working, could you try this other query? It should return the data you want, but for all the projects on team. You could then get only the data where project dbid is 3111.
Remember to replace team-slug by your team slug:

query {
  team(slug: "team-slug") {
    projects {
      edges {
        node {
          title
          dbid
          project_medias {
            edges {
              node {
                media {
                  url
                }
                title
                tags {
                  edges {
                    node {
                      tag_text
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

2 - Permission issue when destroying a Project Media

Team owners can delete any content and team editors can delete only the items created by them.
Could you check what’s the role and status from the user you are using to authenticate, please? And check if the item was created by the same user?
This query shows the role and permission in all teams the authenticated user is associated to:

query {
  me {
    team_users {
      edges {
        node {
          team {
            name
          }
          role
          status
        }
      }
    }
  }
}

You also can check the role on your team’s page https://checkmedia.org/<team-slug>/

Hi Daniela,

Thanks so much for your help with the first issue!

For the second one, when I run the query locally or using the API key to access GraphiQL, I get:

{'data': {'me': {'team_users': {'edges': [{'node': {'role': 'contributor', 'status': 'member', 'team': {'name': 'Daniela'}}}, {'node': {'role': 'editor', 'status': 'member', 'team': {'name': 'HRC-ISchool'}}}]}}}}

When I run without the API key to access GraphiQL, I get:

{"data": {"me": {"team_users": {"edges": [{"node": {"role": "owner", "status": "member", "team": {"name": "HRC-ISchool"}}}]}}}}

The item I attempt to delete was created by ‘HRC-ISchool.’

Hi!

The owner of the content should be able to delete the item.
Just to make sure it’s not a role problem, could you change the Bot’s role? Probably you can only do this from GraphiQL without the API key token.
You should use this query, replacing journalist by owner : https://github.com/meedan/check/wiki/GraphQL-query-examples#update-the-relation-between-a-team-and-a-user

Please tell me if changing the role to owner will let you delete content when you run the query locally.

This worked! Thank you so much!

1 Like