We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I can mock a generic graphQL service with graphql-tools
I cannot use these tools with prisma binding as I cannot pass prisma-bindings an executable schema.
Current work around
create file schema.ts
const schemaPath = path.format({dir: __dirname, base: '../generated/prisma.graphql'}).toString(); export const typeDefs = gql(importSchema(schemaPath));
add below to package.json
"generate": "graphql-binding --language typescript --input src/mocks/Schema.ts --outputBinding src/mocks/generated/MockPrismaBinding.ts"
Then create a file MockPrisma.ts
export const MockPrisma = ( mockList: IMocks, typeResolvers = undefined) => { // Add mocks, modifies schema in place const schema = makeExecutableSchema({ typeDefs, resolvers: typeResolvers}); addMockFunctionsToSchema({ schema , mocks: mockList}); const link = new SchemaLink({schema}); // custom binding generate with graphql-binding --language typescript return new MockPrismaBindings.Binding(link); };
Can now mock in tests like this
const prisma = MockPrisma({ CurationTag: (source, args) => ({ curations: [], user: null, id: args.where.id, name: 'comedy', } as CurationTag) }); const result = await Resolver.type(null, {ids:[]}, {db: prisma} as Context, null);
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I can mock a generic graphQL service with graphql-tools
I cannot use these tools with prisma binding as I cannot pass prisma-bindings an executable schema.
Current work around
create file schema.ts
add below to package.json
Then create a file MockPrisma.ts
Can now mock in tests like this
The text was updated successfully, but these errors were encountered: