nexus-plugin-prisma icon indicating copy to clipboard operation
nexus-plugin-prisma copied to clipboard

Input Object type <ONLYIDSMODEL>UpdateManyDataInput must define one or more fields

Open adarleyjrr opened this issue 4 years ago • 3 comments

Screenshot

image

Description

If a model doesn't have any scalar fields (only own id and other relation ids), like in the OrganizationProfileGroup, then some types generated for update many resolvers of this model are empty. So when I try to run my server I get the input type errors that you can see in the screenshot.

Here's my schema.graphql file generated by nexus with the empty inputs:

input OrganizationResourceGroupUpdateManyDataInput

input OrganizationResourceGroupUpdateManyMutationInput

As a workaround for now I am overwriting the faulty input types with a dummy field in the input by doing:

export const OrganizationProfileGroupUpdateManyDataInput = inputObjectType({
  name: 'OrganizationProfileGroupUpdateManyDataInput',
  definition: (t) => {
    t.int('_', { required: false });
  }
});

export const OrganizationProfileGroupUpdateManyMutationInput = inputObjectType({
  name: 'OrganizationProfileGroupUpdateManyMutationInput',
  definition: (t) => {
    t.int('_', { required: false });
  }
});

Then my generated inputs look like this:

input OrganizationResourceGroupUpdateManyDataInput {
  _: Int
}

input OrganizationResourceGroupUpdateManyMutationInput {
  _: Int
}

And the issue is gone.

I think my issue is related to this: https://github.com/graphql-nexus/nexus-plugin-prisma/issues/648

adarleyjrr avatar Aug 21 '20 14:08 adarleyjrr

I really appreciate the hot fix to this problem. definitely there is something wrong going on.

Screenshot

image #### Description

If a model doesn't have any scalar fields (only own id and other relation ids), like in the OrganizationProfileGroup, then some types generated for update many resolvers of this model are empty. So when I try to run my server I get the input type errors that you can see in the screenshot.

Here's my schema.graphql file generated by nexus with the empty inputs:

input OrganizationResourceGroupUpdateManyDataInput

input OrganizationResourceGroupUpdateManyMutationInput

As a workaround for now I am overwriting the faulty input types with a dummy field in the input by doing:

export const OrganizationProfileGroupUpdateManyDataInput = inputObjectType({
  name: 'OrganizationProfileGroupUpdateManyDataInput',
  definition: (t) => {
    t.int('_', { required: false });
  }
});

export const OrganizationProfileGroupUpdateManyMutationInput = inputObjectType({
  name: 'OrganizationProfileGroupUpdateManyMutationInput',
  definition: (t) => {
    t.int('_', { required: false });
  }
});

Then my generated inputs look like this:

input OrganizationResourceGroupUpdateManyDataInput {
  _: Int
}

input OrganizationResourceGroupUpdateManyMutationInput {
  _: Int
}

And the issue is gone.

I think my issue is related to this: #648

alexander9306 avatar Aug 24 '20 19:08 alexander9306

how about this? I'm facing this issue when create explicit many-to-many relation in prisma.

bolerap avatar Dec 22 '20 08:12 bolerap

Just got this issue too. Any updates on this?

igolka97 avatar Jan 27 '21 19:01 igolka97