Skip to content

Commit f13bf1e

Browse files
piglovesyouLuis Alvarez D
authored andcommitted
[example with-typescript-graphql] Fix type error (vercel#10269)
* fix: Type error * Improve README.md
1 parent 2ff2e9e commit f13bf1e

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

examples/with-typescript-graphql/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# GraphQL and TypeScript Example
1+
# TypeScript and GraphQL Example
22

33
One of the strengths of GraphQL is [enforcing data types on runtime](https://graphql.github.io/graphql-spec/June2018/#sec-Value-Completion). Further, TypeScript and [GraphQL Code Generator](https://graphql-code-generator.com/) (graphql-codegen) make it safer by typing data statically, so you can write truly type-protected code with rich IDE assists.
44

55
This template extends [Apollo Server and Client Example](https://github.com/zeit/next.js/tree/canary/examples/api-routes-apollo-server-and-client#readme) by rewriting in TypeScript and integrating [graphql-let](https://github.com/piglovesyou/graphql-let#readme), which runs [TypeScript React Apollo](https://graphql-code-generator.com/docs/plugins/typescript-react-apollo) in [graphql-codegen](https://github.com/dotansimha/graphql-code-generator#readme) under the hood. It enhances the typed GraphQL use as below.
66

77
```typescript jsx
8-
import { useNewsQuery } from './news.grpahql'
8+
import { useNewsQuery } from './news.graphql'
99

1010
const News: React.FC = () => {
1111
// Typed already️⚡️
@@ -59,7 +59,7 @@ now
5959

6060
## Notes
6161

62-
By default `**/*.graphqls` is recognized as GraphQL schema and `**/*.graphql` as GraphQL documents. If you prefer the other extensions, make sure the settings of the webpack loader in `next.config.js` and `.graphql-let.yml` point to the same files.
62+
By default `**/*.graphqls` is recognized as GraphQL schema and `**/*.graphql` as GraphQL documents. If you prefer the other extensions, make sure the settings of the webpack loader in `next.config.js` and `.graphql-let.yml` are consistent.
6363

6464
Note: Do not be alarmed that you see two renders being executed. Apollo recursively traverses the React render tree looking for Apollo query components. When it has done that, it fetches all these queries and then passes the result to a cache. This cache is then used to render the data on the server side (another React render).
6565
https://www.apollographql.com/docs/react/api/react-ssr/#getdatafromtree

examples/with-typescript-graphql/lib/resolvers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
const resolvers = {
1+
import { IResolvers } from 'apollo-server-micro'
2+
3+
const resolvers: IResolvers = {
24
Query: {
35
viewer(_parent, _args, _context, _info) {
46
return { id: 1, name: 'John Smith', status: 'cached' }

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy