paljs / prisma-tools

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

Option for creating nexus objectType model only, without queries and mutations #145

Closed nafkhanzam closed 3 years ago

nafkhanzam commented 3 years ago

Is there an option for creating nexus objectType model only, without queries and mutations? didn't seem to find one

AhmedElywa commented 3 years ago

Yes, there is one option to do this.

in your pal.js file, you can add this

example

module.exports = {
  backend: {
    generator: 'nexus',
    excludeModels: [{ name: "User", queries: true, mutations: true }];
  },
};
nafkhanzam commented 3 years ago

how about for all models?

AhmedElywa commented 3 years ago

Here are all options https://paljs.com/generator#options-type-definition

module.exports = {
  backend: {
    generator: 'nexus',
    disableQueries: true,
    disableMutations: true,
  },
};
nafkhanzam commented 3 years ago

Here are all options https://paljs.com/generator#options-type-definition

module.exports = {
  backend: {
    generator: 'nexus',
    disableQueries: true,
    disableMutations: true,
  },
};

did exactly this and still generating both

AhmedElywa commented 3 years ago

If you already have any file generated our CLI will not remove it.

nafkhanzam commented 3 years ago

Here's the step that I did:

  1. delete src/graphql/models folder image
  2. write this in pal.js
    module.exports = {
    backend: {
    generator: "nexus",
    output: "src/graphql/models",
    disableQueries: true,
    disableMutations: true,
    },
    };
  3. run pal g
  4. here's the result image
AhmedElywa commented 3 years ago

Yes found it will fix and push new version

AhmedElywa commented 3 years ago

Please upgrade to the last version 2.5.5 and will get a fix for this issue

nafkhanzam commented 3 years ago

Hmm, still having the exact same issue.. setting only disableQueries or disableMutations still generating both.. the excludeModels: [{name: "Doctor", queries: true, mutations: true}] works tho

pal.js

module.exports = {
  backend: {
    generator: "nexus",
    output: "src/graphql/models",
    disableQueries: true,
    disableMutations: true,
    excludeModels: [{name: "Doctor", queries: true, mutations: true}],
  },
};

package.json

...
"dependencies": {
    "@nexus/schema": "^0.17.0",
    "@paljs/cli": "^2.5.5",
    "@paljs/nexus": "^2.5.4",
    "@paljs/plugins": "^2.5.4",
    "@prisma/client": "2.10.1",
    "apollo-server-express": "^2.19.0",
    "axios": "^0.21.0",
    "bcrypt": "^5.0.0",
    "cross-env": "^7.0.2",
    "dotenv-flow": "^3.2.0",
    "express": "^4.17.1",
    "glob": "^7.1.6",
    "graphql": "^15.4.0",
    "graphql-request": "^3.3.0",
    "graphql-scalars": "^1.4.1",
    "graphql-tag": "^2.11.0",
    "jsonwebtoken": "^8.5.1",
    "link-module-alias": "^1.2.0",
    "moment": "^2.29.1",
    "nexus-plugin-prisma": "^0.23.1",
    "node-gcm": "^1.0.3",
    "nodemailer": "^6.4.14",
    "prisma-dbml-generator": "^0.3.1",
    "uuid": "^8.3.1",
    "winston": "^3.3.3",
    "winston-daily-rotate-file": "^4.5.0",
    "zod": "^1.11.10"
  },
...
AhmedElywa commented 3 years ago

I just tested it 2.5.4 have issue 2.5.5 working good.

Please be sure you delete the folder and rerun it.

I can go online with you. If this does not work, please give it another try.

nafkhanzam commented 3 years ago

yeah, still having the issue.. how can I contact you? I dm'ed you via twitter..