You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GraphQL Yoga is a batteries-included cross-platform [GraphQL over HTTP](https://github.com/graphql/graphql-over-http) spec-compliant GraphQL Server using [Envelop](https://envelop.dev), and [GraphQL Tools](https://graphql-tools.com) that runs anywhere.
6
+
GraphQL Yoga is a batteries-included cross-platform [GraphQL over HTTP spec-compliant](https://github.com/enisdenjo/graphql-http/tree/master/implementations/graphql-yoga)GraphQL server powered by [Envelop](https://envelop.dev) and [GraphQL Tools](https://graphql-tools.com) that runs anywhere; focused on easy setup, performance and great developer experience.
7
7
8
8
## Installation
9
9
10
10
import { PackageCmd } from'@theguild/components'
11
11
12
12
<PackageCmdpackages={['graphql graphql-yoga']} />
13
13
14
-
## Usage
14
+
## Schema
15
15
16
-
You will need to provide schema to Yoga, either by an existing executable schema, or by providing your type definitions and resolver map.
16
+
You will need to provide a schema to Yoga, there are many ways to assemble a GraphQL schema, here's just a few:
Use the `createSchema` function included in Yoga. It actually reuses the [`makeExecutableSchema` from @graphql-tools/schema](https://www.graphql-tools.com/docs/generate-schema).
24
+
25
+
```js filename="schema.js"
26
+
import { createSchema } from'graphql-yoga'
27
+
28
+
exportconstschema=createSchema({
29
+
typeDefs:/* GraphQL */`
30
+
type Query {
31
+
hello: String
32
+
}
33
+
`,
34
+
resolvers: {
35
+
Query: {
36
+
hello: () =>'world',
37
+
},
38
+
},
39
+
})
40
+
```
41
+
42
+
</Tab>
43
+
44
+
<Tab>
45
+
46
+
[`makeExecutableSchema` from @graphql-tools/schema](https://www.graphql-tools.com/docs/generate-schema) is very simple, but powerful. Install it and create a schema.
> Yoga uses GraphQL Tools under the hood so you'll want to follow the [`makeExecutableSchema`](https://www.graphql-tools.com/docs/generate-schema) pattern.
110
+
</Tab>
111
+
<Tab>
44
112
45
-
**That is it!**
113
+
Code-first type-safe GraphQL schema without codegen or metaprogramming using [gqtx](https://github.com/sikanhe/gqtx). Install it and create schema.
46
114
47
-
Now visit [`http://localhost:4000/graphql`](http://localhost:4000/graphql) to execute the followiing query operation:
You can also pass an existing `GraphQLSchema` instance to `createServer`.
137
+
<Tab>
58
138
59
-
If you're using a library such as [Pothos](https://pothos-graphql.dev/), [GraphQL Nexus](https://nexusjs.org/), [gqtx](https://github.com/sikanhe/gqtx), or vanilla [`graphql-js`](https://graphql.org/graphql-js/type/#graphqlschema), you simply can pass the `GraphQLSchema` to `schema`:
139
+
[graphql-js](https://github.com/graphql/graphql-js) is a reference implementation of GraphQL for JavaScript. You should already have it installed, just create schema.
0 commit comments