@wayfair/gqmock
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -21,4 +21,5 @@ import { ApolloServer } from '@apollo/server'; | ||
getFieldName(__typename: string): string; | ||
getNewMock({ query, typeName, operationName, rollingKey, }: { | ||
getNewMock({ query, variables, typeName, operationName, rollingKey, }: { | ||
query: string; | ||
variables: Record<string, unknown>; | ||
typeName: string; | ||
@@ -25,0 +26,0 @@ operationName: string; |
@@ -138,3 +138,3 @@ "use strict"; | ||
} | ||
async getNewMock({ query, typeName, operationName, rollingKey, }) { | ||
async getNewMock({ query, variables, typeName, operationName, rollingKey, }) { | ||
const newQuery = (0, buildPrivateTypeQuery_1.default)({ | ||
@@ -149,3 +149,3 @@ query, | ||
query: newQuery, | ||
variables: {}, | ||
variables, | ||
operationName: this.getFieldName('privateQuery'), | ||
@@ -152,0 +152,0 @@ }); |
@@ -143,2 +143,3 @@ "use strict"; | ||
query, | ||
variables, | ||
operationName, | ||
@@ -145,0 +146,0 @@ }); |
@@ -130,5 +130,25 @@ "use strict"; | ||
}, | ||
variableDefinitions: [], | ||
}, | ||
], | ||
}; | ||
const allVariableDefinitions = []; | ||
(0, graphql_1.visit)(queryAst, { | ||
VariableDefinition(node) { | ||
allVariableDefinitions.push(node); | ||
}, | ||
}); | ||
const variableDefinitions = []; | ||
(0, graphql_1.visit)(newQueryAst, { | ||
Variable(node) { | ||
const matchingVariable = allVariableDefinitions.find((definition) => definition.variable.name.value === node.name.value); | ||
if (matchingVariable) { | ||
const addedToDefinitions = variableDefinitions.find((definition) => definition.variable.name.value === node.name.value); | ||
if (!addedToDefinitions) { | ||
variableDefinitions.push(matchingVariable); | ||
} | ||
} | ||
}, | ||
}); | ||
newQueryAst.definitions[0].variableDefinitions = variableDefinitions; | ||
return apolloServerManager.addTypenameFieldsToQuery((0, graphql_1.print)(newQueryAst)); | ||
@@ -135,0 +155,0 @@ } |
import ApolloServerManager from '../ApolloServerManager'; | ||
declare function deepMerge(source: Record<string, unknown>, seed: Record<string, unknown>, graphqlContext: { | ||
query: string; | ||
variables: Record<string, unknown>; | ||
operationName: string; | ||
@@ -5,0 +6,0 @@ apolloServerManager: ApolloServerManager; |
@@ -24,3 +24,3 @@ "use strict"; | ||
async function deepMerge(source, seed, graphqlContext, options = {}) { | ||
const { query, operationName, apolloServerManager } = graphqlContext; | ||
const { query, operationName, apolloServerManager, variables } = graphqlContext; | ||
const warnings = new Set(); | ||
@@ -33,2 +33,3 @@ async function merge(source, target, { rollingKey = '', metaPropertyPrefix = '$' }) { | ||
query, | ||
variables, | ||
typeName: target.__typename, | ||
@@ -49,2 +50,3 @@ operationName, | ||
query, | ||
variables, | ||
typeName: sourceItem.__typename, | ||
@@ -75,2 +77,3 @@ operationName, | ||
query, | ||
variables, | ||
typeName: sourceItem.__typename, | ||
@@ -77,0 +80,0 @@ operationName, |
@@ -1,1 +0,1 @@ | ||
{"name":"@wayfair/gqmock","version":"1.3.0","description":"GQMock - GraphQL Mocking Service","main":"dist/index.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/wayfair-incubator/gqmock.git"},"keywords":["api","federated","federation","gql","graphql","mocking","mock","service"],"author":"@mmazur122","license":"MIT","bugs":{"url":"https://github.com/wayfair-incubator/gqmock/issues"},"files":["dist/**/*"],"homepage":"https://github.com/wayfair-incubator/gqmock#readme","dependencies":{"@apollo/server":"^4.1.1","@apollo/subgraph":"^2.1.3","@babel/runtime":"^7.18.9","@faker-js/faker":"^7.6.0","@graphql-tools/mock":"^8.7.12","chalk":"4.1.2","cors":"^2.8.5","escape-string-regexp":"^4.0.0","express":"^4.18.1","graphql":"^16.6.0","joi":"^17.6.0","lodash":"^4.17.21","node-fetch":"^2.6.7","uuid":"^8.3.2"}} | ||
{"name":"@wayfair/gqmock","version":"1.3.1","description":"GQMock - GraphQL Mocking Service","main":"dist/index.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/wayfair-incubator/gqmock.git"},"keywords":["api","federated","federation","gql","graphql","mocking","mock","service"],"author":"@mmazur122","license":"MIT","bugs":{"url":"https://github.com/wayfair-incubator/gqmock/issues"},"files":["dist/**/*"],"homepage":"https://github.com/wayfair-incubator/gqmock#readme","dependencies":{"@apollo/server":"^4.1.1","@apollo/subgraph":"^2.1.3","@babel/runtime":"^7.18.9","@faker-js/faker":"^7.6.0","@graphql-tools/mock":"^8.7.12","chalk":"4.1.2","cors":"^2.8.5","escape-string-regexp":"^4.0.0","express":"^4.18.1","graphql":"^16.6.0","joi":"^17.6.0","lodash":"^4.17.21","node-fetch":"^2.6.7","uuid":"^8.3.2"}} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
119830
1422