graphql-nexus / nexus

Code-First, Type-Safe, GraphQL Schema Construction
https://nexusjs.org
MIT License
3.4k stars 275 forks source link

#441 breaks the use with raw GraphQLScalarType from library such as graphql-upload-minimal #1166

Open oosawy opened 1 year ago

oosawy commented 1 year ago

When updating nexus from 1.1.0 to latest, the following error occurs. And I found out it can no longer use GraphQLScalarType since 1.2.0-next.14 introduced #983

Error: Schema must contain uniquely named types but contains multiple types named "Upload".
    at new GraphQLSchema (/home/projects/stackblitz-starters-gbnfra/node_modules/graphql/type/schema.js:194:15)
    at makeSchemaInternal (/home/projects/stackblitz-starters-gbnfra/node_modules/nexus/dist/builder.js:1153:20)
    at makeSchema (/home/projects/stackblitz-starters-gbnfra/node_modules/nexus/dist/makeSchema.js:16:84)

Reproduction:

https://stackblitz.com/edit/stackblitz-starters-gbnfra?file=package.json,index.js

Workaround:

cxport const FileUpload = scalarType({
  ...GraphQLUpload,
  asNexusMethod: "upload",
})

const Query = queryType({
  definition(t) {
    t.field('account', {
      type: Account,
      args: {
        avatar: arg({ type: FileUpload }),
      },
    })
  },
})