graphql-hive / graphql-hive/envelop

Apollo client support (community contribution)

Open
#2,256 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
No language data
Stars
827
Forks
132
PR merge metrics
No merged PRs in 30d

Description

Hi there, I have a [server-side rendering use-case](https://github.com/n1ru4l/envelop/discussions/2250) and I wrote a thing for it. It lets you use Envelop with Apollo client.

## Example
```ts
import * as graphqlJs from 'graphql'
import { ApolloClient, gql, InMemoryCache } from '@apollo/client'
import { EnvelopSchemaLink } from '@envelop/apollo-client'
import { envelop, useEngine, useSchema } from '@envelop/core'
import { makeExecutableSchema } from '@graphql-tools/schema'

let schema = makeExecutableSchema({
typeDefs: `type Query { hello: String! }`,
resolvers: {
Query: {
hello: () => 'world'
}
}
})

// Use any enveloped setup
let getEnveloped = envelop({
plugins: [useEngine(graphqlJs), useSchema(schema)]
})
let envelope = getEnveloped()

let apollo = new ApolloClient({
cache: new InMemoryCache(),
// Pass it to EnvelopSchemaLink
link: new EnvelopSchemaLink(envelope)
})

// Use Apollo
let result = await apollo.query({
query: gql`
query {
hello
}
`
})

console.log(result)
```

## Contribution

Here's the diff, would you accept a PR similar to this?
https://github.com/n1ru4l/envelop/compare/main...vladinator1000:envelop:apollo-schema-link?expand=1

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.