-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeScript issue when renaming fields at object type level #91
Comments
The issue is that without any types configured via I've also been considering adding a way of defining the types at runtime and/or maybe also having a way of specifying the root type manually, e.g. import { objectType } = from 'nexus/generics'
export const Card = objectType({
name: "Card",
definition<CardType>(t) {
t.id('id')
}
}) By the way, I'm curious - are you using TypeScript or JavaScript in these examples? |
I like your proposal. However, it would be awesome if Nexus would allow us to do something similar to const Card = stripeObjectType({
name: "Card",
definition(t) {
t.stripeFields([
"id",
"brand",
"last4",
{ name: "exp_month", alias: "expMonth" },
{ name: "exp_year", alias: "expYear" }
])
},
})
I'm using TypeScript with Yoga2. |
@tgriesser I already figured out how to solve my issue based on what you said. However, I am getting errors in some of my As a quick example, this resolver is complaining. My intention is to avoid to rewrite all the interfaces by my own, and use as much as possible from other third-party libraries instead, in my case Stripe, in order to keep my interfaces up-to-date. So, I wanted to override the Stripe interface for the customer object but sadly interfaces can be overridden in TypeScript. I tried many things but I didn't get it working yet. ATM, I have this. Could you check this out and let me know how we can solve this kind of issues within Nexus? If Nexus could allow us to make something like |
You can use the import { core } from 'nexus'
export interface Customer extends core.Omit<Stripe.customers.ICustomer, 'name' | 'lastName'> {
name: string
lastName: string
} |
Marking this as both docs and enhancements. We need better docs on backing types. But we might also want to explore a richer backing types DSL. |
Actually going to focus this issue to just be docs
@jferrettiboke feel free to re-open a feature request/discussion. |
I've just bumped into a requirement which is similar to this that I'm struggling to resolve. I'm not renaming, but generating field A off field B but I don't wish to expose field A which I currently have to do. I can't see anything in the docs to easily solve this. What's the current status of this? |
I'm using Stripe so I created a
Card
object type.I adapted the
Card
object type to exactly what Stripes returns and this works great, however, I want to rename some fields. When I do so this is what happens:If I hover the the red line it says:
Property 'exp_month' does not exist on type '{ brand: string; exp_year: string; id: string; last4: string; }'.
.But if I do this (I left the field that Stripe returns plus my renamed field), it works:
Can we rename fields at the object type level or do we have to do it in the parent? Any idea how to solve this?
The text was updated successfully, but these errors were encountered: