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
Currently Nexus only supports global abstract type strategy settings. In the future however (#623) there may be ways to enable a particular strategy for only a subset of your schema. This way you could for example express that __typename is required in the returned model data of resolvers for one abstract type but require all other objects whom are members of other abstract types to implement isTypeOf.
Ideally something like:
queryType({definition(t){t.field('somethingElse',{type: 'SomethingElse',// ...})t.field('search',{type: 'SearchResult',args: {pattern: stringArg(),},resolve(_,args,ctx){returnctx.db.search(args.pattern).map(result=>{return{
...result,__typename: 'Photo',// <-- This property is __REQUIRED__}})},})},})unionType({name: 'SearchResult',strategy: 'DiscriminantModelField',// <-- Set the strategy only for this abstract typedefinition(t){t.members('Photo'/* ... */)},})objectType({name: 'Photo',definition(t){t.string('url')t.int('width')t.int('height')},})unionType({name: 'SomethingElse',strategy: 'Modular',// <-- Set the strategy only for this abstract typedefinition(t){t.members('Thing1',/* ... */)},})objectType({name: 'Thing1',isTypeOf(data){// <-- REQUIRED b/c object is member of "SomethingElse" which uses Modular strategy// ...},})
The text was updated successfully, but these errors were encountered:
As mentioned in the docs...
Ideally something like:
The text was updated successfully, but these errors were encountered: