Tag: graphql
-
How to mock the external library graphql-request call using jest
0 I’m encountering difficulties while writing Jest unit tests for a module that interacts with graphql-request. Here’s the test import { jest } from ‘@jest/globals’; import { request } from ‘graphql-request’; import { logActivityPhoneCallScheduled, } from ‘./candidateService’; jest.mock(‘graphql-request’, () => { return { request: jest.fn(), }; }); beforeEach(() => { jest.clearAllMocks(); }); test(‘scheduled’, async ()…
-
Access multiple nested TypeScript type generated from GraphQL
0 I need to access only the "departments" type in this large type generated from GraphQL: export type GetCompanyChartQuery = ( { __typename?: ‘Query’ } & { generateOrgChart?: Maybe<( { __typename?: ‘DepartmentNode’ } & Pick<DepartmentNode, ‘name’> & { manager?: Maybe<( { __typename?: ‘EmployeeNode’ } & Pick<EmployeeNode, ‘name’ | ‘mobilePhone’> )>, departments?: Maybe<Array<Maybe<( { __typename?: ‘DepartmentNode’…
-
What is the design pattern for doing Apollo serverside logic
0 To learn GraphQL and Apollo I am working on a Tic Tac Toe game. Currently the way it works is that the server stores all game information so when the client clicks a square, it sends a mutation to the server which updates the GameState type and returns the new state. What I would…
-
Salesforce GraphQL API Pagination: Duplicate Records Returned in Second Page Query
0 salesforce graphql api query accounts, for the second page, using previous endCursor for "after" value, return some duplicate records that already show in the first page. I am using v57 api First page query: query accounts { uiapi { query { Account (first:10) { edges { node { Id Name { value } }…
-
GraphQL Mutation Error: “Field `parts` is not defined by type ‘ProjectInput’”
0 I am working on a GraphQL mutation to create a project with associated phones and their parts, in other words relationship between is so: Phone can have multiple parts. I have defined a schema for querying phones along with their parts. However, I am encountering an error when trying to create a project with…
-
Graphql-request using typescript webpack config set up
0 I have a rest api written in typeScript and one of my downstream API is in Graphql. I am using graphql-request to consume the downstream graphql api. Version in package.json "graphql": "^16.6.0", "graphql-request": "^6.1.0", and my code is import { GraphQLClient, gql } from ‘graphql-request’ export const getUser = async (authToken: AuthToken) => {…
-
How to solve graphql-rquest mockResolvedValue is not a function
0 In my project I’m updating to Node 18 and also converting from commonjs to esm. When I run the Jest tests I’m getting this error TypeError: request.mockResolvedValue is not a function In the following file but as you see the jest.mock()is on top of the scope as per documentation and also what I saw…
-
How to comment in the GraphiQL’s variable section
0 When using GraphiQl how can I make comment’s in the variable section? Is it even possible? For example I can make comment’s in the query section using # like: query ProductVariants($quantityPro: Int!, $quantityVar: Int!) { products(first: $quantityPro) { edges { node { id # Title of the product title variants(first: $quantityVar) { edges {…
-
How to deserialize Graphql Response
0 Hi I have a graphql Response after Mutating {{ "carCreate": { "car": { "id": "TestId" } } }} I want to Desealize it I am using The following Code var graphQlClient = new GraphQLHttpClient(AppConfig.GraphQlUrl, new NewtonsoftJsonSerializer()); I have tried to resolve with the following code var response = await graphQlClient.SendMutationAsync<CarCreate>(request); My Created Model is…