Download next.js/examples/api-routes-graphql/pages/api/graphql.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 629 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/examples/api-routes-graphql/pages/api/graphql.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/examples/api-routes-graphql/pages/api/graphql.ts
-
curl -L -o graphql.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/examples/api-routes-graphql/pages/api/graphql.ts
629 Bytes
| import { createYoga, createSchema } from "graphql-yoga"; | |
| const typeDefs = /* GraphQL */ ` | |
| type Query { | |
| users: [User!]! | |
| } | |
| type User { | |
| name: String | |
| } | |
| `; | |
| const resolvers = { | |
| Query: { | |
| users() { | |
| return [{ name: "Nextjs" }]; | |
| }, | |
| }, | |
| }; | |
| const schema = createSchema({ | |
| typeDefs, | |
| resolvers, | |
| }); | |
| export const config = { | |
| api: { | |
| // Disable body parsing (required for file uploads) | |
| bodyParser: false, | |
| }, | |
| }; | |
| export default createYoga({ | |
| schema, | |
| // Needed to be defined explicitly because our endpoint lives at a different path other than `/graphql` | |
| graphqlEndpoint: "/api/graphql", | |
| }); | |