<@UBER6N7K7> it'd be interesting if we could pass ...
# graphql-nexus
e
@jasonkuhrt it'd be interesting if we could pass in the TS type to a field definition that will override the scalar's type, ex:
Copy code
objectType({
  name: 'User',
  definition: t => {
      t.id<UserId>('id')
  }
})
this is interesting when youre using nominal types, which is something might be builtin to TS one day https://github.com/microsoft/TypeScript/issues/202#issuecomment-695912785
r
Hey @Eric Reis 👋 It would be great if you could open a feature request here.
j
This would require Nexus Schema to use the TS TypeChecker API to find out about the passed generics. Then generate some runtime code that can be used by Nexus Schema to complete its graphql.js type construction. After all this feature would be sending information from the type level to the term level. This is not possible normally (inference makes the reverse possible, though). Overall Possible. But non trivial. Wouldn't benefit JS users either. So its unlikely this will ever get done, tbh.
e
@jasonkuhrt an alternative I believe could work more in lines with nexus internals would be
Copy code
objectType({
    name: 'User',
    definitions: t => {
        t.id('id', {
           typescriptType: {
              name: 'UserID',
              source: 'myTypes'
           },
           // or even
           typeScriptType: 'myTypes.UserID'
        })
    }
})
so the type would be come a source defined in makeSchema
j
Feel free to expand on the idea in a feature request as @Ryan mentioned 🙂
👍 1