Skip to content

Commit edd925b

Browse files
Mark user-provided 'variableValues' as read-only (#2002)
Motivation: graphql/express-graphql#516
1 parent 9b2e626 commit edd925b

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/execution/execute.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export type ExecutionArgs = {|
116116
document: DocumentNode,
117117
rootValue?: mixed,
118118
contextValue?: mixed,
119-
variableValues?: ?{ [variable: string]: mixed, ... },
119+
variableValues?: ?{ +[variable: string]: mixed, ... },
120120
operationName?: ?string,
121121
fieldResolver?: ?GraphQLFieldResolver<any, any>,
122122
typeResolver?: ?GraphQLTypeResolver<any, any>,
@@ -144,7 +144,7 @@ declare function execute(
144144
document: DocumentNode,
145145
rootValue?: mixed,
146146
contextValue?: mixed,
147-
variableValues?: ?{ [variable: string]: mixed, ... },
147+
variableValues?: ?{ +[variable: string]: mixed, ... },
148148
operationName?: ?string,
149149
fieldResolver?: ?GraphQLFieldResolver<any, any>,
150150
typeResolver?: ?GraphQLTypeResolver<any, any>,
@@ -266,7 +266,7 @@ export function addPath(prev: ResponsePath | void, key: string | number) {
266266
export function assertValidExecutionArguments(
267267
schema: GraphQLSchema,
268268
document: DocumentNode,
269-
rawVariableValues: ?ObjMap<mixed>,
269+
rawVariableValues: ?{ +[variable: string]: mixed, ... },
270270
): void {
271271
invariant(document, 'Must provide document');
272272

@@ -291,7 +291,7 @@ export function buildExecutionContext(
291291
document: DocumentNode,
292292
rootValue: mixed,
293293
contextValue: mixed,
294-
rawVariableValues: ?ObjMap<mixed>,
294+
rawVariableValues: ?{ +[variable: string]: mixed, ... },
295295
operationName: ?string,
296296
fieldResolver: ?GraphQLFieldResolver<any, any>,
297297
typeResolver?: ?GraphQLTypeResolver<any, any>,

src/execution/values.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ type CoercedVariableValues = {|
4141
export function getVariableValues(
4242
schema: GraphQLSchema,
4343
varDefNodes: $ReadOnlyArray<VariableDefinitionNode>,
44-
inputs: ObjMap<mixed>,
44+
inputs: { +[variable: string]: mixed, ... },
4545
): CoercedVariableValues {
4646
const errors = [];
4747
const coercedValues = {};

src/graphql.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export type GraphQLArgs = {|
5757
source: string | Source,
5858
rootValue?: mixed,
5959
contextValue?: mixed,
60-
variableValues?: ?{ [variable: string]: mixed, ... },
60+
variableValues?: ?{ +[variable: string]: mixed, ... },
6161
operationName?: ?string,
6262
fieldResolver?: ?GraphQLFieldResolver<any, any>,
6363
typeResolver?: ?GraphQLTypeResolver<any, any>,
@@ -69,7 +69,7 @@ declare function graphql(
6969
source: Source | string,
7070
rootValue?: mixed,
7171
contextValue?: mixed,
72-
variableValues?: ?{ [variable: string]: mixed, ... },
72+
variableValues?: ?{ +[variable: string]: mixed, ... },
7373
operationName?: ?string,
7474
fieldResolver?: ?GraphQLFieldResolver<any, any>,
7575
typeResolver?: ?GraphQLTypeResolver<any, any>,
@@ -118,7 +118,7 @@ declare function graphqlSync(
118118
source: Source | string,
119119
rootValue?: mixed,
120120
contextValue?: mixed,
121-
variableValues?: ?{ [variable: string]: mixed, ... },
121+
variableValues?: ?{ +[variable: string]: mixed, ... },
122122
operationName?: ?string,
123123
fieldResolver?: ?GraphQLFieldResolver<any, any>,
124124
typeResolver?: ?GraphQLTypeResolver<any, any>,

src/subscription/subscribe.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export type SubscriptionArgs = {|
2828
document: DocumentNode,
2929
rootValue?: mixed,
3030
contextValue?: mixed,
31-
variableValues?: ?{ [variable: string]: mixed, ... },
31+
variableValues?: ?{ +[variable: string]: mixed, ... },
3232
operationName?: ?string,
3333
fieldResolver?: ?GraphQLFieldResolver<any, any>,
3434
subscribeFieldResolver?: ?GraphQLFieldResolver<any, any>,
@@ -64,7 +64,7 @@ declare function subscribe(
6464
document: DocumentNode,
6565
rootValue?: mixed,
6666
contextValue?: mixed,
67-
variableValues?: ?{ [variable: string]: mixed, ... },
67+
variableValues?: ?{ +[variable: string]: mixed, ... },
6868
operationName?: ?string,
6969
fieldResolver?: ?GraphQLFieldResolver<any, any>,
7070
subscribeFieldResolver?: ?GraphQLFieldResolver<any, any>,
@@ -187,7 +187,7 @@ export function createSourceEventStream(
187187
document: DocumentNode,
188188
rootValue?: mixed,
189189
contextValue?: mixed,
190-
variableValues?: ?{ [variable: string]: mixed, ... },
190+
variableValues?: ?{ +[variable: string]: mixed, ... },
191191
operationName?: ?string,
192192
fieldResolver?: ?GraphQLFieldResolver<any, any>,
193193
): Promise<AsyncIterable<mixed> | ExecutionResult> {

0 commit comments

Comments
 (0)