#graphql #tooling #web development

A gentle introduction to GraphQL API integrations

GraphQL is a great alternative to REST (or other HTTP API designs). This is an quick introduction to the core concepts around consuming a GraphQL API. To see some examples consuming a GraphQL API: In Python, see Python GraphQL client requests example using gql In JavaScript (browser and Node), see last week’s Code with Hugo newsletter What is GraphQL and what problems does it solve? GraphQL is “a query language for your API”. ...

  • Hugo Di Francesco
    Author
5 min read
#python #graphql #web development

Python GraphQL client requests example using gql

An example consuming a GraphQL API from Python using gql. Full code example at HugoDF/python-graphql-client-example. This was sent out on the Code with Hugo newsletter last Monday. Subscribe to get the latest posts right in your inbox (before anyone else). $ pip install gql # You should use a virtualenvfrom gql import gql, Client from gql.transport.requests import RequestsHTTPTransport _transport = RequestsHTTPTransport( url='https://graphql-pokemon.now.sh/', use_json=True, ) client = Client( transport=_transport, fetch_schema_from_transport=True, ) query = gql(""" { pokemon(name: "Pikachu") { attacks { special { name } } } } """) print(client. ...

  • Hugo Di Francesco
    Author
1 min read