• Stars
    star
    108
  • Rank 321,259 (Top 7 %)
  • Language
    TypeScript
  • Created over 4 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Easily use GraphQL in Svelte, powered by the production-ready Relay runtime.

Svelte Relay Logo

Svelte Relay

Easily use GraphQL in Svelte, powered by the production-ready Relay runtime.

Features

Relay bindings for Svelte.

Example

1. Set the Relay Environment into the context

<script>
	import { setRelayEnvironment } from 'svelte-relay';
	import myEnvironment from './environment';

	setRelayEnvironment(myEnvironment);
</script>

2. Write Queries

<script>
	import { getQuery } from 'svelte-relay';
	// This is defined in the next section below.
	import Artist from './Artist';

	const query = getQuery(
		graphql`
			query ArtistQuery($artistID: String!) {
				# The root field for the query
				artist(id: $artistID) {
					# A reference to your fragment container
					...ArtistHeader_artist
				}
			}
		`,
		{
			artistID: 'some-id',
		},
	);
</script>

{#await $query}
	<div>Loading</div>
{:then data}
	<Artist artist="{data.artist}" />
{:catch error}
	<div>{error.message}</div>
{/await}

3. Use Fragments

<script>
	import { getFragment } from 'svelte-relay';

	export let artist;

	const data = getFragment(
		graphql`
			# This fragment is declaring that this component
			# needs an Artist, and these specific fields on
			# the Artist in order to render. Relay will
			# guarantee that this data is fetched and available
			# for this component.
			fragment ArtistHeader_artist on Artist {
				href
				bio
				name
				image {
					url
				}
			}
		`,
		artist,
	);
</script>

<a href="{data.href}">
	<img src="{data.image.url}" />
	<div>
		<h1>{data.name}</h1>
		<h3>{data.bio}</h3>
	</div>
</a>

More Repositories

1

with-react-hooks

Add support for React Hooks in your class components. Live your own life and break the rules.
JavaScript
181
star
2

ethereal-react

A suspense-compatible React library for Ethereum development
TypeScript
130
star
3

HostyHosting

A platform to easily manage and deploy your applications.
TypeScript
92
star
4

acorn-dynamic-import

JavaScript
45
star
5

jeopardy-bot

πŸ’₯ ​A Slack bot for Jeopardy! games. πŸ’₯
TypeScript
31
star
6

relay-workshop-demo

TypeScript
19
star
7

text-me-maybe

TypeScript
18
star
8

iou-nft

Solidity
11
star
9

vanilla-tailwind

An experiment to implement a subset of TailwindCSS in vanilla-extract.
TypeScript
9
star
10

truwu

TypeScript
7
star
11

nextjs-prisma

TypeScript
7
star
12

graphql-rpc

TypeScript
7
star
13

uwu

TypeScript
6
star
14

subscriptions-transport-uws

πŸ”ƒ A WebSocket client + server for GraphQL subscriptions (based on Β΅WS)
JavaScript
5
star
15

annotated-prop-types

Add extra info to your React PropTypes.
JavaScript
4
star
16

characters

Just some characters
TypeScript
4
star
17

magic-api

Treat your APIs like the rest of your code, and just call functions!
TypeScript
3
star
18

react-yoga

JavaScript
3
star
19

typescript-talk

JavaScript
3
star
20

thrift-native

Native thrift bindings for Node.js
C++
3
star
21

stream-notes

Notes from my stream.
JavaScript
2
star
22

graphql-schema-subset

Generate subsets of your GraphQL Schema.
TypeScript
2
star
23

api-resource

Helpful wrappers for API interactions, based on fetch.
2
star
24

Enjo

Enyo Syntax, Jo UI
JavaScript
2
star
25

nytro-web3

2
star
26

potionseller

2
star
27

mcface

Descriptiony McDescriptionface
JavaScript
2
star
28

apollo-restify

Apollo Server 2 Restify Middleware
TypeScript
2
star
29

space-jam-ui

why?
TypeScript
1
star
30

walkie-talkie

You know what it is
JavaScript
1
star
31

chess-bot

A slack bot that plays chess.
JavaScript
1
star
32

jeopardy-bot-rewritten

A rewritten version of Jeopardy Bot, written live on stream: http://vapejuicejordan.rip
TypeScript
1
star
33

VapeJuiceJordan

1
star
34

frequency

Frequency Study
JavaScript
1
star
35

injectable.js

feature injection in javascript
JavaScript
1
star