Skip to main content

Introduction

GraphQL queries allow you to fetch data from your EverShop application. This page documents all available queries across the application’s extensions.

Query Structure

Queries in EverShop follow the standard GraphQL query syntax:

Sample Extension Queries

The sample extension demonstrates basic query patterns with the Foo type.

Query: foo

Fetch a single Foo object by ID.
ID!
required
The unique identifier of the Foo object
Foo
Returns a Foo object or null if not found

Query: foos

Fetch all Foo objects.
[Foo!]!
Returns an array of all Foo objects (never null)

Product Extension Queries

The productCatalog extension extends the core Product type with supplement-specific data.

Extended Type: Product

When querying products, you can access supplement information through the extension field.
ProductExtension
Additional product data extensions

Query Examples in Components

Here’s how to use GraphQL queries in page components:

Basic Query Example

extensions/sample/src/pages/frontStore/fooList/FooList.tsx

Query with Arguments

Query Best Practices

Request Only What You Need

Only query the fields you actually need to reduce data transfer and improve performance.

Use Fragments

Use GraphQL fragments to reuse common field selections across multiple queries.

Handle Null Values

Always check for null values in your components when fields are nullable.

Use Variables

Use query variables instead of string interpolation for dynamic values.

Error Handling

Queries can return errors in the response:
Always check both the data and errors fields in the GraphQL response.

Creating Custom Queries

To add a new query to your extension:
  1. Define the query in your GraphQL schema:
  2. Implement the resolver:
  3. Use it in your components:

Next Steps

GraphQL Mutations

Learn how to modify data with mutations

GraphQL Overview

Review GraphQL architecture and concepts