Encountered an unhandled exception: Unable to identify a GraphQL output type for the "anticipatedInvestmentSupportInfo"

I created a custom DTO named UploadedInvestmentDocumentInput and linked it to the expectedInvestmentSupportInfo property, but an error is occurring:

uncaughtException: Cannot determine a GraphQL output type for the "expectedInvestmentSupportInfo".
 
 Make sure your class is decorated with an appropriate decorator. 
Error: Cannot determine a GraphQL output type for the "expectedInvestmentSupportInfo". 
Make sure your class is decorated with an appropriate decorator.

opportunity-account.input.ts

import { UploadedDocumentInput } from '@app/dto/common.input';
import {
  Field,
  InputType, OmitType, PickType, registerEnumType,
} from '@nestjs/graphql';
import { Type } from 'class-transformer';
import { IsEnum, ValidateNested } from 'class-validator';

import {
  ExpectedInvestmentSupportInfoType,
  SourceOfFundsType,
} from '@/generated-cbms-api-client';

import { OpportunityAccount } from './opportunity-account.response';

registerEnumType(SourceOfFundsType, { name: 'SourceOfFundsType' });
registerEnumType(ExpectedInvestmentSupportInfoType, { name: 'ExpectedInvestmentSupportInfoType' });

@InputType()
export class UploadedInvestmentDocumentInput extends OmitType(UploadedDocumentInput, ['documentType'], InputType) {
  @IsEnum(ExpectedInvestmentSupportInfoType)
  @Field(() => ExpectedInvestmentSupportInfoType)
  documentType: ExpectedInvestmentSupportInfoType;
}

@InputType()
export class UpsertAnticipatedInvestmentActivitiesInput extends PickType(
  OpportunityAccount,
  [
    'isPlanningInvestIn12Months',
    'anticipatedInvestmentOpportunitiesCountRange',
    'investmentDescription',
  ],
  InputType,
) {
  @ValidateNested({ each: true })
  @Type(() => UploadedInvestmentDocumentInput)
  @Field(() => [UploadedInvestmentDocumentInput], { description: 'Expected investment support info' })
  expectedInvestmentSupportInfo: UploadedInvestmentDocumentInput[];
}

UploadedDocumentInput ( common DTO )

import { Field, InputType } from '@nestjs/graphql';
import { FileUpload, GraphQLUpload } from 'graphql-upload';

@InputType()
export class UploadedDocumentInput {
  @Field(() => Number)
  documentType: number;

  @Field(() => GraphQLUpload)
  frontSideDoc: FileUpload;

  @Field(() => GraphQLUpload, { nullable: true })
  backSideDoc?: FileUpload;
}

opportunity-account.output.ts

class UploadedInvestmentDocumentResponse extends OmitType(UploadedDocumentResponse, ['documentType'], InputType) {
  @IsEnum(ExpectedInvestmentSupportInfoType)
  @Field(() => ExpectedInvestmentSupportInfoType)
  documentType: ExpectedInvestmentSupportInfoType;
}

@ObjectType()
export class OpportunityAccount extends AccountsCommonDetails {
  @IsMongoId()
  @Field(() => String, { description: 'Customer id' })
  customerId: string;

// I believe issue is here ( when I commented out the field below, this error vanished !)

  @IsEnum(UploadedInvestmentDocumentResponse)
  @ValidateNested({ each: true })
  @Type(() => UploadedInvestmentDocumentResponse)
  @Field(() => [UploadedInvestmentDocumentResponse], { description: 'Expected investment support info' })
  expectedInvestmentSupportInfo: UploadedInvestmentDocumentResponse[];

 

}

What decorator or property am I missing that is causing the above error to appear?

Answer №1

To ensure proper functionality, I found it necessary to include the ObjectType decorator in the

UploadedInvestmentDocumentResponse
and eliminate the InputType from
OmitType(UploadedDocumentResponse, ['documentType'])
. This adjustment was crucial as I am designing an object that corresponds to a response field rather than an input field!

opportunity-account.output.ts

@ObjectType()
class UploadedInvestmentDocumentResponse extends OmitType(UploadedDocumentResponse, ['documentType']) {
  @IsEnum(ExpectedInvestmentSupportInfoType)
  @Field(() => ExpectedInvestmentSupportInfoType)
  documentType: ExpectedInvestmentSupportInfoType;
}

@ObjectType()
export class OpportunityAccount extends AccountsCommonDetails {
  @IsMongoId()
  @Field(() => String, { description: 'Customer id' })
  customerId: string;

// It seems like the issue lies here (the error disappeared when I removed the following field!)

  @IsEnum(UploadedInvestmentDocumentResponse)
  @ValidateNested({ each: true })
  @Type(() => UploadedInvestmentDocumentResponse)
  @Field(() => [UploadedInvestmentDocumentResponse], { description: 'Expected investment support info' })
  expectedInvestmentSupportInfo: UploadedInvestmentDocumentResponse[];

 

}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What could be causing my HTML to not display properly after making changes to a text node?

Can a DOM text node be altered in such a way: node.nodeValue = "foo <strong> bar </strong>" so that it displays the HTML correctly? Appreciate any help. ...

Unspecified data returned from PHP script via jQuery AJAX

Encountering an issue while trying to use AJAX to get a PHP response from a form. The JavaScript appears to be correct as it functions when the content of login_ajax.php is reduced to just: echo 'CORRECT' //or echo 'INCORRECT' Howev ...

What exactly does the 'value' attribute do when used in an input element within React?

Can someone explain the significance of value={} in React inputs? Currently, I am working with a state defined as const [username, setUsername] = useState("");. In my form, there is an input element that updates the state based on user input. &l ...

Obtain the PHP function output through asynchronous JavaScript and XML programming

I have a form that collects user input and saves it to the database. After submitting the form, an ajax call is made to the action.php file. e.preventDefault(); $.ajax({ type: "POST", url: "action.php", data: senData, dataType: "JSON", ...

Issue with Angular's ngOnChanges Lifecycle Hook Preventing Function ExecutionWhen attempting to run a function within Angular's ngOn

In the midst of my evaluation process to ensure that specific values are properly transmitted from one component to another using Angular's custom Output() and EventEmitter(), I am encountering some issues. These values are being sent from the view of ...

Creating route paths within a single .js file

I'm a beginner when it comes to Node/Express, and I have a question about my app structure. Here is a simplified version of how my app is set up: /app /routes filter.js index.js app.js In my app.js file, I have defined my routes like th ...

Unique Timer with progress bar that resets only when the page is refreshed

We're currently developing a screening tool with a section for questions. Beneath each question, there is a progress bar displaying the time remaining. However, the progress bar only updates when the page is reloaded. Here is the code snippet: publi ...

Strategies for digitally boosting review numbers

I am currently developing an application with the following tasks at hand: Creating two models - Product and reviews on Product. I have successfully created a Schema for Product and implemented all APIs (add product, read product, read product by id, updat ...

What steps can I take to avoid cross-project contamination within an Angular workspace?

Imagine having a project structured like this: projects |-app1 |-app2 |-common node_modules pakcage.json tsconfig.json angular.json ... (other root files) Currently, in a file within app1, you can have an import statement like this: import { Repository } ...

What is the most efficient way to organize JSON data in a tree structure using JavaScript?

I have a JSON data structure that I need to transform into a different format. The original JSON format: values = an array containing objects that need to be filtered by action === 'commented' comment = an object with the comment, n Tasks, and ...

Advanced TypeScript Types - The issue of Unreachable errors within generic functions

I'm struggling to understand why the switch statement in my generic function isn't able to cast my types within its branches. This is my code: interface Id { id: number; } enum Kind { square = "square", circle = "circle" } interface Circle { ki ...

Strict mode does not allow duplicate data properties in object literals within JavaScript

Challenge Description I am facing an issue with handling an optional variable called ByteRange. To accommodate this, I included 2 different URLs in the $resource. Upon doing so, I encountered the following error: Message: Error in parsing: "tools/tes ...

Updating the AngularJS view following a deletion process

I have a web application developed using AngularJS and Rails that carries out RESTful operations like create, read, and delete. After deleting an item, I need to refresh the page and update the view asynchronously. However, I am facing challenges in imple ...

Attempting to intercept a 401 error in an HTTP interceptor, I aim to refresh my session and then retry the initial request

My goal is to intercept responses returning from the /api, catching them if they are a 401 error, executing a refresh session action, and then retrying the original HTTP call again (while also preventing it from infinitely looping if another 401 error occu ...

Nextjs server needs to restart for updates from getServerSideProps to reflect

Initially, I believed that using getServerSideProps would automatically update the data whenever the page is reloaded. However, in my specific scenario, this does not seem to be the case. In the situation where an admin accesses this page, a button will a ...

The Meteor Call object stands apart from the Meteor Method object that was received

When I send an object from the client to the server using a Meteor Call and Meteor method, something strange happens. The object is received in the Method but it looks different - nested within the giftList. Meteor Call - JSON.stringify {"personName& ...

Using JQuery to animate elements by sliding them up, adding a delay, and then sliding them back down

Is there a way to implement sliding up the header with a delay and then sliding it back down repeatedly? Currently, I have a function bound to the form submission but the sliding action only occurs the first time. Here is the code snippet: $(document).rea ...

When working with React, encountering a "TypeError: is not a function" message from a function prop can

I am a beginner with React and I'm attempting to pass a function as a prop to a child component. In this scenario, the parent component looks like this: const [gameStarted, setGameStarted] = useState(false); const [gameSettings, setGameSettings] = use ...

Updating bump map in Three.js not working as expected

I have successfully loaded a model with the corresponding material file (.mtl) into my scene. I am now adding a bump map to it after loading: var mtlLoader = new THREE.MTLLoader(); mtlLoader.setPath('/models/'); mtlLoader ...

Stop automatic resizing on mobile device after postback

Encountered an issue with a website I'm currently developing. It's not causing any problems, but I want to enhance the user experience. My aim is to maintain the zoom levels of mobile devices after a postback. To provide more context, there is a ...