Python GQL Example

from gql import Client, gql
from gql.transport.aiohttp import AIOHTTPTransport

token = '<token>'
transport = AIOHTTPTransport(url='https://api.hypi.app/graphql',
                             headers={
                                 'Authorization': token,
                                 'hypi-domain': '<instance domain>'
                             })
client = Client(transport=transport, fetch_schema_from_transport=True)


def find():
    query = gql(
        """
        {
          find(type: Cell, arcql: "*") {
            edges {
              node {
                ... on Cell {
                  image
                  label
                }
              }
              cursor
            }
          }
        }
    """
    )

    # params = {"code": "EU"}

    return client.execute(query)

def addCells():
    query = gql(
        """
        mutation AddCells {
          upsert(values:{
            Cell:[
              {
                hypi: {id: "cell1"}
                image:"img1",
                label: 1
              },
             {
                hypi: {id: "cell2"}
                image:"img2",
                label: 4
             }
            ]
          }){id}
        }
    """
    )

    # params = {"code": "EU"}

    return client.execute(query)

print(addCells())
print(find())

Hello, I’ve gotten some errors regarding the upsert both in the example that you have provided as well as my own instance. Here are the errors:

{
“data”: null,
“errors”: [
{
“message”: “Exception while fetching data (/upsert) : Unexpected error whilst executing database query - Error ID:01F8QCVBT0CNJ8WG5ZB33Y4TQT”,
“locations”: [
{
“line”: 2,
“column”: 3
}
],
“path”: [
“upsert”
],
“extensions”: {
“DBException”: “Unexpected error whilst executing database query - Error ID:01F8QCVBT0CNJ8WG5ZB33Y4TQT”
}
}
]
}

gql.transport.exceptions.TransportQueryError: {‘message’: ‘Exception while fetching data (/upsert) : Unexpected error whilst executing database query - Error ID:01F8QBTNNT0JMY3E0TGWHV7KEY’, ‘locations’: [{‘line’: 2, ‘column’: 3}], ‘path’: [‘upsert’], ‘extensions’: {‘DBException’: ‘Unexpected error whilst executing database query - Error ID:01F8QBTNNT0JMY3E0TGWHV7KEY’}}

Is there a solution to this problem?

Thank you so much

I reviewed that error ID and it says the table does not exist.
To debug your exact situation let’s try to answer a few thing:

  1. Do you have a table called Cell in your schema?
  2. If you have multiple apps/release/instances, did you set the domain to the one containing this table?
  3. This should be the case but is your release published? Your table will not be created on the server until the release is published.

I recommend watching the Hypi intro demo here

This is 30 mins long but covers a lot of the basics.