Does anyone use nexus-prisma with `Upload` type su...
# orm-help
b
Does anyone use nexus-prisma with
Upload
type supported by Apollo server? How to use it? 😄
g
You can define the Upload scalar like the following: https://nexus.js.org/docs/api-scalartype & import GraphQLUpload from graphql-upload (https://github.com/jaydenseric/graphql-upload/blob/master/src/GraphQLUpload.mjs) Then reference it to your definition, e.g:
Copy code
...
definition(t) {
    t.string("name", { required: true })
    t.id("author", { required: true })
    t.field("avatar", { type: 'Upload' })
  }
b
Nice, I didn't know how to implement Upload scalar type, now it's clearer for me. Thanks!
b
Copy code
import { inputObjectType, scalarType, objectType, asNexusMethod } from 'nexus'
import { string } from 'yup';
import { GraphQLUpload } from 'graphql-upload';

import { GraphQLDate } from "graphql-iso-date";

export const GQLDate = asNexusMethod(GraphQLDate, "date");

export const CreateEventInput = inputObjectType({
  name: 'CreateEventInput',
  definition(t) {
    t.id('id', { required: true })
    t.string('name', { required: true })
  },
})

export const Upload = asNexusMethod(GraphQLUpload, "upload");


export const UploadFileInput = objectType({
  name: 'UploadFileInput',
  definition(t) {
    t
  },
})


export const arrMutationInputs = [
  CreateEventInput,
  UploadFileInput
]
Can any one help me why t.date or t.upload is not available? @bkstorm
b
@Bruce He I’m not sure about your error because I don’t use
asNexusMethod
.
Copy code
t.field('field-name', {
type: 'Upload'
})
you can use this way.