Skip to content
New issue

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

[nexus] Input types generation as a file #196

Closed
durdenx opened this issue Mar 25, 2021 · 1 comment
Closed

[nexus] Input types generation as a file #196

durdenx opened this issue Mar 25, 2021 · 1 comment
Assignees
Labels
feature New feature or request generator generator package

Comments

@durdenx
Copy link

durdenx commented Mar 25, 2021

Hi,
Thanks for the lib!

Is it possible to generate nexus input types as a file instead of runtime generation? We want to customize the default input types. It would be great if the generator generated input types alongside other files (types, query and mutations).

@AhmedElywa
Copy link
Collaborator

Hi by version 3.3.1 you can customize your inputs by adding new options to the paljs plugin

import { makeSchema } from 'nexus'
import * as types from './types'
import { paljs } from '@paljs/nexus'
import { join } from 'path'

export const schema = makeSchema({
  types,
  nonNullDefaults: {
    output: true,
  },
  plugins: [
    paljs({
// exclude all fields with this names from any input
      excludeFields: [
        'password',
        'passwordResetToken',
        'tokenValidDate',
        'passResetExpires',
      ],
// take the input and make your filters then return the fields you want to add 
filterInputs: (input: DMMF.InputType) => input.fields.filter(field => filed.name !== 'password');
    }),
  ],
  outputs: {
    schema: join(__dirname, '../src/generated/schema.graphql'),
    typegen: join(__dirname, '../src/generated/nexus.ts'),
  },
  contextType: {
    module: join(__dirname, 'context.ts'),
    export: 'Context',
  },
})

@durdenx durdenx closed this as completed May 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request generator generator package
Projects
None yet
Development

No branches or pull requests

2 participants