FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
dthyresson
dthyressongraphQLYogaDeferAndStream
Remix of dthyresson/graphQLYoga
Public
Like
graphQLYogaDeferAndStream
Home
Code
2
README.md
H
main.tsx
Branches
1
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in miliseconds.
Sign up now
Code
/
Code
/
Search
Open in new tab
README.md

GraphQL Yoga Server with Defer and Stream

GraphQL Yoga from The Guild is a batteries-included cross-platform GraphQL over HTTP spec-compliant GraphQL server powered by Envelop and GraphQL Tools focused on easy setup, performance and great developer experience.

This is an example of a GraphQL Yoga val with defer and stream features.

Defer and Stream

Defer and stream are directives that allow you to improve latency for clients by sending the most important data as soon as it’s ready.

Usage

To access GraphiQL - the GraphQL Playground - visit the / route. That's what you see in the preview pane below.

Defer

The @defer directive allows you to post-pone the delivery of one or more (slow) fields grouped in an inlined or spread fragment. Visit / and paste the following operation into the left panel.

query SlowAndFastFieldWithDefer { ... on Query @defer { slowField } fastField }

Stream

The @stream directive allows you to stream the individual items of a field of the list type as the items are available. Visit / and paste the following operation into the left panel.

query MyStream { alphabet @stream }

Configuration and Documentation

See the GraphQL Yoga documentation for configuration and all the bells and whistles.

Endpoint

For this example, we'll set to / to make it easier to demo.

However, by default, the GraphQL route is configured to be on /graphql which is more common.

Create val
const yoga = createYoga({ schema, })

You can set a custom endpoint:

Create val
const yoga = createYoga({ schema, graphqlEndpoint: "/my-gql", })

Landing Page

A landing page is shown be default whenever a 404 is hit.

You can disable it via the landingPage option.

Create val
const yoga = createYoga({ schema, landingPage: false })

Migrated from folder: GraphQL/graphQLYogaDeferAndStream

Code
README.md
H
main.tsx
Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.