2018-11-14 13:13:15 +03:00
|
|
|
.. _first_graphql_query:
|
|
|
|
|
2018-09-11 14:11:24 +03:00
|
|
|
Making your first GraphQL query
|
|
|
|
===============================
|
|
|
|
|
2018-12-03 15:12:24 +03:00
|
|
|
.. contents:: Table of contents
|
|
|
|
:backlinks: none
|
|
|
|
:depth: 1
|
|
|
|
:local:
|
|
|
|
|
2019-09-11 10:17:14 +03:00
|
|
|
Let's create a sample table and query data from it using the Hasura console, a UI tool meant for doing exactly this:
|
2018-09-11 14:11:24 +03:00
|
|
|
|
|
|
|
Create a table
|
|
|
|
--------------
|
|
|
|
|
|
|
|
Head to the Hasura console, navigate to ``Data -> Create table`` and create a sample table called ``profile`` with
|
|
|
|
the following columns:
|
|
|
|
|
2019-02-06 09:39:36 +03:00
|
|
|
.. code-block:: sql
|
|
|
|
|
|
|
|
profile (
|
|
|
|
id INT PRIMARY KEY,
|
|
|
|
name TEXT
|
|
|
|
)
|
2018-09-11 14:11:24 +03:00
|
|
|
|
2019-03-13 13:03:45 +03:00
|
|
|
.. thumbnail:: ../../../img/graphql/manual/getting-started/create-profile-table.png
|
2018-09-11 14:11:24 +03:00
|
|
|
|
2019-02-06 09:39:36 +03:00
|
|
|
Now, insert some sample data into the table using the ``Insert Row`` tab of the ``profile`` table.
|
2018-09-11 14:11:24 +03:00
|
|
|
|
|
|
|
Try out a query
|
|
|
|
---------------
|
|
|
|
|
|
|
|
Head to the ``GraphiQL`` tab in the console and try running the following query:
|
|
|
|
|
|
|
|
.. code-block:: graphql
|
|
|
|
|
|
|
|
query {
|
|
|
|
profile {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
You'll see that you get all the inserted data!
|
|
|
|
|
2019-03-13 13:03:45 +03:00
|
|
|
.. thumbnail:: ../../../img/graphql/manual/getting-started/profile-query.png
|
2018-09-11 14:11:24 +03:00
|
|
|
|
|
|
|
Next steps
|
|
|
|
----------
|
|
|
|
|
|
|
|
Read more about:
|
|
|
|
|
|
|
|
- :doc:`Building your schema <../schema/index>`
|
|
|
|
- :doc:`Queries <../queries/index>`
|
|
|
|
|