[GH-ISSUE #41] Add ability to add argument names of a variable #119

Closed
opened 2026-03-15 11:33:09 +03:00 by kerem · 0 comments
Owner

Originally created by @Devorein on GitHub (Jun 29, 2020).
Original GitHub issue: https://github.com/atulmy/gql-query-builder/issues/41

For example:-

const gqlquery = query([
	{
		operation: 'someoperation',
		fields: [
			{
				operation: 'nestedoperation',
				fields: [],
				variables: {
					id2: {
						type: 'ID',
						value: 123
					}
				}
			}
		],
		variables: {
			id1: {
				type: 'ID',
				value: 456
			}
		}
	}
]);

// Output

query ($id2: ID, $id1: ID) { someoperation (id1: $id1) { nestedoperation (id2: $id2) {  } } }

Maybe add the ability in the variable definition to add a name property to change the argument name

const gqlquery = query([
	{
		operation: 'someoperation',
		fields: [
			{
				operation: 'nestedoperation',
				fields: [],
				variables: {
					id2: {
						type: 'ID',
						value: 123,
						name: 'id'
					}
				}
			}
		],
		variables: {
			id1: {
				type: 'ID',
				value: 456,
				name: 'id'
			}
		}
	}
]);

// Output

query ($id2: ID, $id1: ID) { someoperation (id: $id1) { nestedoperation (id: $id2) {  } } }

By default it could be the keyname but, I think adding the ability to separate the argument name and variable name could be helpful in some instances. Let me try to submit a PR resolving this issue

Originally created by @Devorein on GitHub (Jun 29, 2020). Original GitHub issue: https://github.com/atulmy/gql-query-builder/issues/41 For example:- ```js const gqlquery = query([ { operation: 'someoperation', fields: [ { operation: 'nestedoperation', fields: [], variables: { id2: { type: 'ID', value: 123 } } } ], variables: { id1: { type: 'ID', value: 456 } } } ]); // Output query ($id2: ID, $id1: ID) { someoperation (id1: $id1) { nestedoperation (id2: $id2) { } } } ``` Maybe add the ability in the variable definition to add a name property to change the argument name ```js const gqlquery = query([ { operation: 'someoperation', fields: [ { operation: 'nestedoperation', fields: [], variables: { id2: { type: 'ID', value: 123, name: 'id' } } } ], variables: { id1: { type: 'ID', value: 456, name: 'id' } } } ]); // Output query ($id2: ID, $id1: ID) { someoperation (id: $id1) { nestedoperation (id: $id2) { } } } ``` By default it could be the keyname but, I think adding the ability to separate the argument name and variable name could be helpful in some instances. Let me try to submit a PR resolving this issue
kerem closed this issue 2026-03-15 11:33:14 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/gql-query-builder#119
No description provided.