Tag: typescript
-
How to get Typescript to compile custom GraphQL Scalars
-1 This very simple GraphQL Custom Scalar fails with the typescript error: TS2351: This expression is not constructable. Type ‘typeof import("…/graphql/node_modules/graphql/index")’ has no construct signatures. import GraphQLScalarType, { GraphQLInt } from ‘graphql’; export const CustomScalar = new GraphQLScalarType({ …GraphQLInt, name: "CustomScalar" }) what needs to be changed to get Typescript to compile it? typescript graphql…
-
Dictionary in GraphQL resolver of NestJS
1 In my NestJS project I’m creating a GraphQL endpoint for a service that returns a dictonary object: { [key: number]: MyDataDto } In my .interfaces.ts file I would like to have something like: interface ArrayAsObject<T> { [key: number]: T } @ObjectType() export class MyDataDtoAsDictionary implements ArrayAsObject<MyDataDto> { @Field(() => MyDataDto) [key: number]: MyDataDto }…
-
How to create Shopify Order Discount App? [closed]
-4 Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 51 mins ago. Improve this question I am trying to create a Shopify order discount app. I have installed the…
-
Rename types with graphql-codegen
4 I’m working on a legacy codebase where, in our GraphQL schema, an interface was defined as ‘Subscription’: interface Subscription { fieldOne: String fieldTwo: String } type FirstSubscriptionType implements Subscription { anotherField: String } type SecondSubscriptionType implements Subscription { yetAnotherField: String } This has worked fine (we don’t use subscriptions and don’t have plans to),…
-
GraphQL Codegen issue: Unable to load template plugin matching ‘typescript-common’
-1 I am trying to setup GraphQL Code Generator. But I get this error: gql-gen –config codegen.ts ✔ Parse Configuration ⚠ Generate outputs ❯ Generate to src/graphql/generated/schema.ts ✔ Load GraphQL schemas ✔ Load GraphQL documents ✖ Unable to load template plugin matching ‘typescript-common’. Reason: Body must be a string. Received: undefined. ELIFECYCLE Command failed with…
-
TypeError with Pothos Graphql and prisma-plugin
0 I am building a social app with nextjs for frontend and SSR, graphql-yoga server, and pothos for typesafe graphql and prisma for my db. I have followed all the example given in all their documentation for integration. However, I am getting a confusing error. ERR Error: Type Post must define one or more fields.…
-
Conditionally render an Astro component based on page type query
0 I am using Astro, GraphQL (Apollo Client), Typescript and React. In my dynamic route: […slug].astro file I need to conditionally render a certain Astro component. I managed to that with: {data.page.type === ‘PageOneType’ && <PageOne />} {data.page.type === ‘PageTwoType’ && <PageTwo />} Can I somehow make this more dynamic, so I don’t have to…
-
How to show Astro component based on a certain field and map the correct data and Astro component in the dynamic slug page
0 I am using Astro, GraphQL (Apollo Client), Typescript and React. For now I think don’t need React yet. I have a dynamic route: […slug].astro I have the following query: export default gql` query Page($pageTarget: String!) { page(pageTarget: $pageTarget) { type content { … on PageOne { id title } … on PageTwo { id…
-
Use dynamically type of generic
0 export const createBill = /* GraphQL */ `mutation CreateBill( $input: CreateBillInput! $condition: ModelBillConditionInput ) { createBill(input: $input, condition: $condition) { periodStart periodEnd energy senderId receiverId metering_point_number file_key customer_number bill_number paid interval id createdAt updatedAt __typename } } ` as GeneratedMutation< APITypes.CreateBillMutationVariables, APITypes.CreateBillMutation >; I have this graphql query wich is automatically generated. Now i…