Is it possible to add new values to a GraphQL query?

I am currently utilizing GraphQL and Typeorm in conjunction with an Oracle Database, specifically focusing on retrieving all data from a specific table. The query that is being executed is:

SELECT "inventory"."id" AS "inventory_id", "inventory"."value" AS "inventory_value", "inventory"."description" AS "inventory_description" FROM "inventory" "inventory"

However, it should actually be:

SELECT "inventory"."id" AS "inventory_id", "inventory"."value" AS "inventory_value", "inventory"."description" AS "inventory_description" FROM "dbname.inventory"

The database referenced as "dbname" is connected through a Public Oracle Database Link.

I am wondering if there is a way for me to add "dbname." to the table segment of the GraphQL query or if there is a more efficient approach to address this issue?

Below are my model and resolver files. Please feel free to reach out with any inquiries or suggestions. Thank you in advance and do not hesitate to ask for clarification on anything.

// Inventory.ts
import { Entity, PrimaryGeneratedColumn, Column, BaseEntity } from "typeorm";
import { ObjectType, Field } from "type-graphql";

@Entity()
@ObjectType()
export class inventory extends BaseEntity {
  @PrimaryGeneratedColumn("uuid") id: number;

  @Field()
  @Column({ type: "varchar" })
  value: number;

  @Field()
  @Column({ type: "varchar" })
  description: string;
  
}
// InventoryResolver.ts
import { Resolver, Query } from "type-graphql";
import { inventory } from "../../models/Inventory";

@Resolver(inventory)
export class InventoryResolver {
  constructor() {}

  @Query(() => inventory, { nullable: true })
  async queryInventory() {
    return inventory.find();
  }
}

Answer №1

The challenge does not pertain to the resolver in type-graphql. Simply include the database name in the configuration of the @Entity decorator. As per the documentation on typeorm's decorator reference:

...
@Entity({
  name: "inventory"
  database: "dbname", // <-- 
})
@ObjectType()
export class inventory extends BaseEntity {
...

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

How can you display the value of a date type in a TextField?

I'm currently utilizing the TextField component from material-ui. My goal is to display the current date in the TextField and allow users to select another date. Is this feasible? When using type="date", the value set as {date} does not show up in th ...

A single click is required for Observables to load on an HTML page

While working on my Angular web application, I encountered an issue with displaying data when using Observables and Subjects. Typically, when searching the Firebase DB, I use *ngFor="let myvar of _myvar | async" in my HTML to display the retrieve ...

The left-hand operator in Typescript is not valid

I am a beginner in typescript and I have been following a tutorial called Tour of Heroes on Angular's website. In the final chapter of the tutorial, when I tried to use HTTP with the provided code, everything seemed to run fine but I encountered an er ...

What is the best way to bring in this interface from the React-Particles-JS library?

I have been attempting to segregate my parameters from my JSX within the react-particles-js library. I organize my parameters in an Object: let config = { "particles": { "number": { "value": 50 }, ...

Exploring TypeScript's Classes and Generics

class Person { constructor(public name: string) {} } class Manager extends Person {} class Admin extends Person {} class School { constructor(public name: string) {} } function doOperation<T extends Person>(person: T): T { return person; } ...

Triggering a client-side dialog in Electron-Angular upon receiving an IPC event

I am experiencing a strange issue with my back-end notification system and client-side Angular Material dialog component. There are times when the dialog does not fully instantiate, even though the constructor of the component is invoked. The component&apo ...

Steps for specifying the required type of an Object literal in Typescript

Let's analyze a straightforward code snippet interface Foo{ bar:string; idx:number; } const test1:Foo={bar:'name'}; // this is highly recommended as it includes all required fields const test2={bar:'name'} as Foo; // this is ...

How to access saved values in WebdriverIo using Typescript

I am currently using WebdriverIO along with Typescript for automating an Android app. Scenario: Go to the Training Page Get the Session name (This value changes dynamically) I want to store the retrieved session name in a variable and then later assert ...

The string property I pass to the List component with the flexDirection style is meant to be implemented, but unfortunately, an error occurs

When passing a string property ("raw" | "column") to the List component which has a flexDirection style property, I encounter an error: Type '{ direction: String; }' is not assignable to type 'FlexDirection | undefined'. 7 | ...

Issue with linear Graham scan method causing failure when computing convex hull of basic polygon

It is said that the Graham scan algorithm can efficiently find the convex hull of a simple polygon in linear time without requiring the nlogn sorting step since the vertices are already effectively sorted. I have implemented the Graham scan algorithm, and ...

When using Angular 10 or later, the mouseclick event will consistently trigger Angular's change detection mechanism

When I bind an event to elements on a component's HTML page, the component continues to detect changes even when the element event is fired. Despite setting the change detection mode of the component to OnPush, this behavior persists. To test this, I ...

"Utilizing variadic tuple types to implement the pipe function in TypeScript 4: A step-by-step guide

An illustration from the release notes of TypeScript 4 demonstrates the use of variadic tuple types to eliminate multiple overload definitions. It seems feasible to type the pipe function for any number of arguments. type F<P, R> = (p: P) => R ty ...

What is the true function of the `as` keyword within a mapped type?

I am new to typescript and I find the usage of as confusing in the following example. type foo = "a" | "b" | 1 | 2; type bar = { [k in foo as number]: any } This example passes type checking. The resulting bar type is transformed i ...

Tailoring Aurelia for .cshtml integration

I stumbled upon an informative article detailing the integration of Razor partials (cshtml) with aurelia. Despite my efforts, I encountered difficulty in getting the code to execute properly and was informed by Rob Eisenberg's comment that Convention ...

The error message "TypeError: text is not a function" is displayed when trying to utilize the text() method from either Blob

My current dilemma revolves around the usage of functions defined in the typescript lib.dom.d.ts file within my node.js express backend that is implemented using TypeScript. Specifically, I am encountering issues with the File/Blob interfaces where a File ...

What is the reason for the lack of variable assignment within the forEach method in Angular?

I am struggling with assigning a value to the variable "this.qdDias" and returning it. After using subscribe, I am unable to retrieve the value at the end of the method. Despite seeing the value in the console.log(this.qdDias), it becomes undefined when re ...

Creating a List programatically in material-ui can be easily achieved by following these steps

I am attempting to create a contact view using the list component from Material-UI. My code is written in typescript, but I am struggling with setting up react and material-ui correctly. Any guidance would be greatly appreciated. export interface IConta ...

"Enhancing user experience with MaterialUI Rating feature combined with TextField bordered outline for effortless input

I'm currently working on developing a custom Rating component that features a border with a label similar to the outlined border of a TextField. I came across some helpful insights in this and this questions, which suggest using a TextField along with ...

How can one change the data type specified in an interface in TypeScript?

I am currently diving into TypeScript and looking to integrate it into my React Native application. Imagine having a component structured like this: interface Props { name: string; onChangeText: (args: { name: string; value: string }) => void; s ...

"Encountering issues with DefinePlugin when using the combination of Ionic, Angular, Webpack,

I'm trying to incorporate my process.env variable into the webpack Bundle using DefinePlugin. Here's the snippet of code in my webpack config: plugins: [ new webpack.DefinePlugin({ 'process.env': JSON.stringify(process.env) ...