paljs / prisma-tools

Prisma tools to help you generate CRUD system for GraphQL servers
https://paljs.com
MIT License
684 stars 54 forks source link

Providing usable examples for paljs #125

Closed martineboh closed 4 years ago

martineboh commented 4 years ago

Thanks for your work!

I find it really hard to use prisma-tools because enough example code isn't provided, just bunch of interfaces. I have been trying to generate SDL from my schema.prisma file for days now with no success using pal g command, even after creating pal.json in my root directory with schema.prisma in the prisma directory relative to root.

AhmedElywa commented 4 years ago

If you using pal.json you need to pass his name to pal g command like pal g -c pal.json if you using pal.js so you can use pal g without any custom flags in the command

Also, you not provided any errors message that sees what is wrong with you to help you

martineboh commented 4 years ago

Thanks for responding so quickly. It doesn't show any error, just displayed Generating your files in just a second. I am using pal.js with content: !!! - I am not using TS.

module.exports = {
    schemaFolder: '/prisma',
    backend: {
        models: ['Profile', 'Senator'],
        generator: 'sdl',
        onDelete: true,
        excludeQueriesAndMutations: ['aggregate']
    }
};

I ran pal g in the root directory - it generated src/graphql folder with the wrong Models: Course, Group, Post, Product, User...with their corresponding typeDefs and resolvers.ts that are not in my schema.prisma file.

PS: Also how do I use the below with the Option args:

import { Generator } from '@paljs/generator';
import { generateGraphQlSDLFile } from '@paljs/plugins';
import typeDefs from './graphql/typeDefs';
import resolvers from './graphql/resolvers';

let schema = makeExecutableSchema({ typeDefs, resolvers });

// Build one sdl file have all types you can delete if you not need
generateGraphQlSDLFile(schema);
AhmedElywa commented 4 years ago

Talk to me in Prisma slack

AhmedElywa commented 4 years ago

So the problem you need to run prisma generate command first before pal g command