Skip to content

Queries

Siddhant Srivastav edited this page Jan 25, 2019 · 1 revision

GraphQL queries are used to fetch data from the server.

Queries for the entire codebase reside in the file app/shared/queries.

All tables of the database tracked by the GraphQL engine can be queried over the GraphQL endpoint. If you have a tracked table in your database, its query field is added as a nested field under the query_root root level type.

For querying username id name from the table user, the following query is used

	query {
		user {
			id
			username
			name
		}
	}

Generic Queries

The following query will take value of the variable userId and use it to create a dynamic query.

	query ($userId: Int!) {
		user (where: {id: {_eq: $userId}}) {
			id
			username
			name
		}
	}

For more details about writing queries, please visit Hasura Documentation for Queries