paljs / prisma-tools

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

sdlInputs on v5.0.0 onwards #287

Closed simmons-kyle closed 1 year ago

simmons-kyle commented 1 year ago

I was encountering the same issue mentioned on #283 however upon upgrading to the latest version of @paljs/plugins (5.0.3) I can see that the implementation of the sdlInputs import has changed.

Firstly the documented example throws an error on the import for sdlInputs:

import { dmmf } from './prismaCustomPath';
import { mergeTypeDefs } from '@graphql-tools/merge';
import { sdlInputs } from '@paljs/plugins'; // << Module '"@paljs/plugins"' has no exported member 'sdlInputs'.ts(2305)

export default mergeTypeDefs([
  sdlInputs({
    dmmf,
    excludeFields: ['password'],
    filterInputs: (input) => input.fields.filter((field) => field.name !== 'passowrd'),
  }),
  ...customTypes,
]);

Looking at the source it seems like packages/plugins/src/sdlInputs.ts was drastically changed in the commit for v5.0.0 to only contain one function for generateGraphQlSDLFile and that's it - is the implementation of sdlInputs elsewhere in the @paljs/plugins package now? Is there documentation on how it should be used going forward?

AhmedElywa commented 1 year ago

As we said in the v5.0.0 notes we have breaking changes https://github.com/paljs/prisma-tools/releases/tag/v5.0.0

// src/graphql/typeDefs.ts
- import { sdlInputs } from '@paljs/plugins';
+ import InputTypes from './InputTypes';

- export default mergeTypeDefs([sdlInputs()]);
+ export default mergeTypeDefs([InputTypes]);
AhmedElywa commented 1 year ago

You don't need to dmmf again you need to move

excludeFields: ['password'],
 filterInputs: (input) => input.fields.filter((field) => field.name !== 'passowrd'),

to pal.config.js file

simmons-kyle commented 1 year ago

Ah sorry I totally missed the notes about the change to sdlInputs - my mistake.

However after installing v5.0.3 when I run pal g I'm not finding the InputTypes being created. I initially thought it was due to the fact I was using the javaScript: true flag in the config but even removing that so it generates in typescript does not yield the InputTypes folder after pal g executes.

AhmedElywa commented 1 year ago

You need to upgrade the @paljs/cli too

simmons-kyle commented 1 year ago

I knew it would be something simple like that - thank you!