You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's an example of how we we gqtx today to be able to avoid duplicating code between implementers of the ILedger interface.
constLedgerInterface=t.interfaceType<Raw.Ledger>({name: 'ILedger',fields: ()=>[t.abstractField({name: 'id',type: t.String}),t.abstractField({name: 'name',type: t.String}),t.abstractField({name: 'users',type: t.List(LedgerUserType)}),],})/** * Way to share implemention of the LedgerInterface * Need to figure out how to share the `users` implementation between books and tabs * Or perhaps better to not differentiate at all? */functionmakeLedgerSubtype(options: {name: stringisTypeOf: (l: Raw.Ledger)=>booleanfields: ()=>Array<Field<GQLContext,Raw.Ledger,unknown,{}>>}){returnt.objectType<Raw.Ledger>({name: options.name,interfaces: [LedgerInterface],isTypeOf: options.isTypeOf,fields: ()=>[t.field({name: 'id',type: t.String}),t.field({name: 'name',type: StringType}),t.field({name: 'users',type: t.List(UserType),// resolve: (ledger, __, ctx) =>}),
...options.fields(),],})}
It's a bit cumbersome, but still better than duplicating the code. In an ideal world the LedgerInterface would just be able to contain the implementation details (optionally) and avoid needing to duplicate all together.
The text was updated successfully, but these errors were encountered:
Here's an example of how we we gqtx today to be able to avoid duplicating code between implementers of the
ILedger
interface.It's a bit cumbersome, but still better than duplicating the code. In an ideal world the LedgerInterface would just be able to contain the implementation details (optionally) and avoid needing to duplicate all together.
The text was updated successfully, but these errors were encountered: