k0ff33
11/20/2018, 2:46 PMgraphqlgen as well but don’t know how to configure it properly. Is there a guide on how to pair it both together?mpacholec
11/20/2018, 5:23 PMk0ff33
11/20/2018, 5:35 PMgraphql codegen properly. The examples are just for a yoga server standalone.mpacholec
11/20/2018, 5:36 PMmpacholec
11/20/2018, 5:36 PMk0ff33
11/20/2018, 5:37 PMmpacholec
11/20/2018, 5:38 PMmpacholec
11/20/2018, 5:38 PMmpacholec
11/20/2018, 5:39 PMmpacholec
11/20/2018, 5:43 PMk0ff33
11/20/2018, 5:44 PMgraphqlgen requires to pass a context in the graphqlgen.yml which is defined as a function in the boilerplate: https://github.com/graphql-boilerplates/typescript-graphql-server/blob/master/advanced/src/index.ts#L8k0ff33
11/20/2018, 5:44 PMmpacholec
11/20/2018, 5:47 PMmpacholec
11/20/2018, 5:48 PMmpacholec
11/20/2018, 5:48 PMmpacholec
11/20/2018, 5:49 PMexport interface Context {
myDataSource: RESTDataSource;
headers: string[];
}mpacholec
11/20/2018, 5:49 PMmpacholec
11/20/2018, 5:49 PMmodelmpacholec
11/20/2018, 5:50 PMmpacholec
11/20/2018, 5:50 PMk0ff33
11/20/2018, 5:50 PMgraphql codegenk0ff33
11/20/2018, 5:51 PMcontext prop at all, I get Error occurred while reading schema: Error: Field feed: Couldn't find type Post in any of the schemas.mpacholec
11/20/2018, 5:51 PMmpacholec
11/20/2018, 5:51 PMmpacholec
11/20/2018, 5:52 PMmpacholec
11/20/2018, 5:52 PMmpacholec
11/20/2018, 5:52 PMmpacholec
11/20/2018, 5:53 PMmpacholec
11/20/2018, 5:53 PMk0ff33
11/20/2018, 5:53 PMdatamodel.graphqlmpacholec
11/20/2018, 5:54 PMgraphqlgen.ymlmpacholec
11/20/2018, 5:54 PMk0ff33
11/20/2018, 5:54 PMgraphql create my-app --boilerplate typescript-advanced, it will create the same structure as I’m using atmmpacholec
11/20/2018, 5:54 PMmpacholec
11/20/2018, 5:54 PMk0ff33
11/20/2018, 5:54 PMmpacholec
11/20/2018, 5:56 PMgraphqlgen.ymlmpacholec
11/20/2018, 5:56 PMlanguage: typescript
schema: ./src/schema.graphql
context: ./src/types.ts:Context
models:
files:
- ./src/generated/prisma-client/index.ts
output: ./src/generated/graphqlgen.ts
resolver-scaffolding:
output: ./src/generated/tmp-resolvers/
layout: file-per-typempacholec
11/20/2018, 5:56 PMk0ff33
11/20/2018, 5:56 PMk0ff33
11/20/2018, 5:57 PMlanguage: typescript
schema: ./src/schema.graphql
# context: ./src/index.ts
models:
files:
- ./src/generated/prisma.ts
output: ./src/generated/graphqlgen.ts
resolver-scaffolding:
output: ./src/generated/tmp-resolvers/
layout: file-per-typempacholec
11/20/2018, 5:57 PMmpacholec
11/20/2018, 5:57 PMmpacholec
11/20/2018, 5:57 PMmpacholec
11/20/2018, 5:58 PMk0ff33
11/20/2018, 5:59 PMk0ff33
11/20/2018, 5:59 PMcontext: Points to the definition of the context object that’s passed through your GraphQL resolver chain.It’s not clear to me with my setup
k0ff33
11/20/2018, 5:59 PMmpacholec
11/20/2018, 5:59 PMk0ff33
11/20/2018, 5:59 PMmpacholec
11/20/2018, 6:00 PMmpacholec
11/20/2018, 6:00 PMexport interface Context {
someField: any;
}mpacholec
11/20/2018, 6:00 PMmpacholec
11/20/2018, 6:01 PMmpacholec
11/20/2018, 6:01 PMmpacholec
11/20/2018, 6:01 PMmpacholec
11/20/2018, 6:01 PMmpacholec
11/20/2018, 6:01 PMmpacholec
11/20/2018, 6:01 PMk0ff33
11/20/2018, 6:02 PMk0ff33
11/20/2018, 6:02 PMexport interface Context {
data: any
}
it complains: Error occurred while reading schema: Error: Field feed: Couldn't find type Post in any of the schemas.k0ff33
11/20/2018, 6:03 PMmpacholec
11/20/2018, 6:03 PMmpacholec
11/20/2018, 6:03 PMmpacholec
11/20/2018, 6:03 PMk0ff33
11/20/2018, 6:04 PMk0ff33
11/20/2018, 6:04 PMmpacholec
11/20/2018, 6:04 PMmpacholec
11/20/2018, 6:05 PMk0ff33
11/20/2018, 6:05 PMContext interface with data: any rather than providing an actual Data interface?k0ff33
11/20/2018, 6:05 PMexport interface Context {
data: any
}
// vs
export interface Context {
data: Data
}
export interface User {
id: string
name: string | null
postIDs: string[]
}
export interface Post {
id: string
title: string
content: string
published: boolean
authorId: string
}
export interface Data {
posts: Post[]
users: User[]
idProvider: () => string
}mpacholec
11/20/2018, 6:06 PMmpacholec
11/20/2018, 6:06 PMdata: any just for examplempacholec
11/20/2018, 6:06 PMk0ff33
11/20/2018, 6:07 PMContext interface fit inmpacholec
11/20/2018, 6:07 PMmpacholec
11/20/2018, 6:07 PMmpacholec
11/20/2018, 6:07 PMcontext: req => ({
...req,
db: new Prisma({
endpoint: process.env.PRISMA_ENDPOINT, // the endpoint of the Prisma API (value set in `.env`)
debug: true, // log all GraphQL queries & mutations sent to the Prisma API
// secret: process.env.PRISMA_SECRET, // only needed if specified in `database/prisma.yml` (value set in `.env`)
}),
}),mpacholec
11/20/2018, 6:07 PMmpacholec
11/20/2018, 6:07 PMk0ff33
11/20/2018, 6:07 PMmpacholec
11/20/2018, 6:08 PMmpacholec
11/20/2018, 6:08 PMmpacholec
11/20/2018, 6:08 PMtype in this situationk0ff33
11/20/2018, 6:09 PMContextParameters && Prisma?mpacholec
11/20/2018, 6:09 PMexport interface Context {
[header: string]: string;
db: Prisma;
}mpacholec
11/20/2018, 6:09 PMreq will be speadedmpacholec
11/20/2018, 6:10 PMk0ff33
11/20/2018, 6:11 PMimport { Prisma } from './generated/prisma'
import { ContextParameters } from 'graphql-yoga/dist/types'
export interface Context extends ContextParameters {
db: Prisma
}k0ff33
11/20/2018, 6:12 PMContextParameters import was auto completed from vscode 🤷mpacholec
11/20/2018, 6:12 PMmpacholec
11/20/2018, 6:12 PMmpacholec
11/20/2018, 6:13 PMmpacholec
11/20/2018, 6:13 PMk0ff33
11/20/2018, 6:14 PMmpacholec
11/20/2018, 6:14 PMk0ff33
11/20/2018, 6:14 PMmpacholec
11/20/2018, 6:15 PMmpacholec
11/20/2018, 6:15 PMexport type Context = { [key: string]: any }mpacholec
11/20/2018, 6:15 PMmpacholec
11/20/2018, 6:16 PMmpacholec
11/20/2018, 6:16 PMexport interface Context {
[key: string]: any;
db: Prisma;
}k0ff33
11/20/2018, 6:16 PMmpacholec
11/20/2018, 6:16 PMmpacholec
11/20/2018, 6:16 PMmpacholec
11/20/2018, 6:17 PMmpacholec
11/20/2018, 6:17 PMContext interface more specificmpacholec
11/20/2018, 6:17 PMMyVeryCoolContext 😛mpacholec
11/20/2018, 6:18 PMk0ff33
11/20/2018, 6:21 PMmpacholec
11/20/2018, 6:21 PMk0ff33
11/20/2018, 6:22 PMContext interfacempacholec
11/20/2018, 6:22 PMk0ff33
11/20/2018, 6:22 PMk0ff33
11/20/2018, 6:22 PMk0ff33
11/20/2018, 6:26 PMContext interface in `utils.ts`: https://github.com/graphql-boilerplates/typescript-graphql-server/blob/master/advanced/src/utils.ts#L4k0ff33
11/20/2018, 6:27 PMexport interface Context {
db: Prisma
request: any
}k0ff33
11/20/2018, 6:27 PMk0ff33
11/20/2018, 6:27 PMmpacholec
11/20/2018, 7:40 PMrequest: any shouldn't be therempacholec
11/20/2018, 7:41 PMcontext: (request) => ({}) and it's returning context objectmpacholec
11/20/2018, 7:41 PM