How to use the gql.gql function in gql

To help you get started, we’ve selected a few gql examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github graphql-python / gql / tests / starwars / test_validation.py View on Github external
def validation_errors(client, query):
    query = gql(query)
    try:
        client.validate(query)
        return False
    except Exception:
        return True
github graphql-python / gql / tests / starwars / test_query.py View on Github external
def test_check_type_of_r2(client):
    query = gql('''
        query CheckTypeOfR2 {
          hero {
            __typename
            name
          }
        }
    ''')
    expected = {
        'hero': {
            '__typename': 'Droid',
            'name': 'R2-D2',
        }
    }
    result = client.execute(query)
    assert result == expected
github itolosa / orionx-api-client / examples / site_queries.py View on Github external
}
  }
''')

params = {
  "code": "BTC"
}

operation_name = "getWallet"

print(client.execute(query, variable_values=params))

# me
# wallet
# currency
query = gql('''
  query getCurrencyInfo($code: ID!) {
    me {
      _id
      __typename
    }
    wallet(code: $code) {
      _id
      __typename
    }
    currency(code: $code) {
      code
      units
      round
      symbol
      format
      isCrypto
github itolosa / orionx-api-client / examples / site_queries.py View on Github external
__typename
      }
      hasTwoFactor
      __typename
    }
  }
''')

params = {}

operation_name = "getMyTwoFactorSettings"

print(client.execute(query, variable_values=params))

# markets
query = gql('''
  query getMarkets {
    clpMarkets: markets(secondaryCurrencyCode: \"CLP\") {
      ...exchangeNavbarMarkets
      __typename
    }
    btcMarkets: markets(secondaryCurrencyCode: \"BTC\") {
      ...exchangeNavbarMarkets
      __typename
    }
  }

  fragment exchangeNavbarMarkets on Market {
    code
    name
    lastTrade {
      price
github mavlink / MAVSDK / tools / generate_changelog.py View on Github external
def query_releases(gql_client, debug=False):
    query_releases = gql('''
            {
              repository(owner: "mavlink", name: "MAVSDK") {
                releases(last: 10) {
                  nodes {
                    name
                    createdAt
                    tag {
                      name
                    }
                  }
                }
              }
            }
            ''')
github itolosa / orionx-api-client / examples / site_queries.py View on Github external
__typename
    }
    __typename
  }
''')

params = {
  "code": "CHACLP"
}

operation_name = "getMarket"

print(client.execute(query, variable_values=params))

# orders
query = gql('''
  query myOrders($marketCode: ID!) {
    orders(marketCode: $marketCode, onlyOpen: true, limit: 0) {
      totalCount
      items {
        _id
        sell
        type
        amount
        amountToHold
        secondaryAmount
        filled
        secondaryFilled
        limitPrice
        createdAt
        isStop
        status
github itolosa / orionx-api-client / examples / site_queries.py View on Github external
variation
      __typename
    }
  }
'''),
params = {
  "marketCode": "CHACLP"
}

operation_name = "marketCurrentStats"

print(client.execute(query, variable_values=params))


# marketEstimateAmountToRecieve
query = gql('''
  query getEstimate($marketCode: ID!, $amount: Float!, $sell: Boolean!) {
    estimate: marketEstimateAmountToRecieve(marketCode: $marketCode, amount: $amount, sell: $sell)
  }
''')

params = {
  "marketCode": "CHACLP",
  "amount": 1,
  "sell": False
}

operation_name = "getEstimate"

print(client.execute(query, variable_values=params))

# marketOrderBook
github willianantunes / flask-playground / flask_playground / services / github_graphql_api.py View on Github external
def total_number_of_followers(github_username_login: str) -> int:
    query = gql(
        f"""
            query {{
              user(login:"{github_username_login}") {{
                followers {{
                  totalCount
                }}
              }}
            }}        
        """
    )
    result = _execute(lambda: _get_client().execute(query))
    return result["user"]["followers"]["totalCount"]
github wandb / client / wandb / apis / internal.py View on Github external
entityName: $entityName,
                projectName: $projectName,
                controller: $controller,
                scheduler: $scheduler
            }) {
                sweep {
                    name
                    _PROJECT_QUERY_
                }
            }
        }
        '''
        # FIXME(jhr): we need protocol versioning to know schema is not supported
        # for now we will just try both new and old query
        mutation_new = gql(mutation_str.replace("_PROJECT_QUERY_", project_query))
        mutation_old = gql(mutation_str.replace("_PROJECT_QUERY_", ""))

        # don't retry on validation errors
        # TODO(jhr): generalize error handling routines
        def no_retry_400_or_404(e):
            if not isinstance(e, requests.HTTPError):
                return True
            if e.response.status_code not in (400, 404):
                return True
            body = json.loads(e.response.content)
            raise UsageError(body['errors'][0]['message'])

        for mutation in mutation_new, mutation_old:
            try:
                response = self.gql(mutation, variable_values={
                    'id': obj_id,
                    'config': yaml.dump(config),
github wandb / client / wandb / apis / internal.py View on Github external
Args:
            project (str): The project to download
            files (list or dict): The filenames to upload
            run (str, optional): The run to upload to
            entity (str, optional): The entity to scope this project to.  Defaults to wandb models

        Returns:
            (bucket_id, file_info)
            bucket_id: id of bucket we uploaded to
            file_info: A dict of filenames and urls, also indicates if this revision already has uploaded files.
                {
                    'weights.h5': { "url": "https://weights.url" },
                    'model.json': { "url": "https://model.json", "updatedAt": '2013-04-26T22:22:23.832Z', 'md5': 'mZFLkyvTelC5g8XnyQrpOw==' },
                }
        """
        query = gql('''
        query Model($name: String!, $files: [String]!, $entity: String!, $run: String!, $description: String) {
            model(name: $name, entityName: $entity) {
                bucket(name: $run, desc: $description) {
                    id
                    files(names: $files) {
                        edges {
                            node {
                                name
                                url(upload: true)
                                updatedAt
                            }
                        }
                    }
                }
            }
        }