Title
s

shane

07/31/2019, 10:01 PM
Does anybody know how to generate nullable array fields with nexus? example would be:
const foo = inputObjectType({
  name: 'foo',
  definition(t) {
    t.string('bar', { list: true, nullable: true })
  }
})
generated input is always:
input foo {
  bar: [String!]
}
desired outcome would be:
input foo {
  bar: [String]
}
h

harmony

07/31/2019, 11:04 PM
why would you want that
the array is optional, it just can't contain null values, which are a footgun anyways
s

shane

08/01/2019, 3:19 AM
Because that’s how the existing web and native clients are making the graphql query. Also prior to using nexus with manually creating the schema you can do that. Not to mention if you can define the option to be null able you’d think the generated schema would adhere to what you defined.
Also I need the ability to send an empty array
h

Harshit

08/01/2019, 4:21 PM
@shane You can do that like so:
t.string("test", {
      list: [false],
      nullable: true,
    })
s

shane

08/01/2019, 4:29 PM
@Harshit you’re A. Amazing but 7 minutes too late…we JUST figured it out using the SDL converter with my old schema…. but I thank you so much!
🙌 1
🍻 1
😅 1
need to utilize that converter more
it’s a nice tool
👍 1
h

harmony

08/01/2019, 8:30 PM
it's just a really bad idea to have an optional array / nulls in an array
and you can always migrate from nullable to non nullable on the server
🤷