Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getUser: {
user: params(
{ id: 1 },
{
id: types.number,
name: types.string,
bankAccount: {
id: types.number,
branch: types.string,
},
},
),
},
}
const gqlString = query(getUserQuery)
console.log(gqlString)
// =>
// query getUser(id: 1) {
// user {
// id
// name
// bankAccount {
// id
// name
// }
// }
// }
async function run() {
// We would like to type this!
// if (isDefined(basicFundingEligibility[fundingSource].vaultable)) {
// delete fundingQuery[fundingSource].vaultable;
// }
if (isDefined(basicFundingEligibility[fundingSource].branded)) {
delete fundingQuery[fundingSource].branded;
}
if (!Object.keys(fundingQuery[fundingSource]).length) {
delete fundingQuery[fundingSource];
}
}
}
return query('GetFundingEligibility', params(InputTypes, {
fundingEligibility: params(Inputs, fundingQuery)
}));
}
async function run() {
// We would like to type this!
const result: typeof getUserQuery = await executeGraphql(query(getUserQuery))
// As we cast `result` to `typeof getUser`,
// Now, `result` type looks like this:
// interface result {
// getUser: {
// id: number
// name: string
// bankAccount: {
// id: number
// branch: string
// }
// }
// }
}
const queryObj = {};
queryObj[`get_${entryId}`] = params(
Object.keys(data).reduce((result, key) => {
result[key] = `"${data[key]}"`;
return result;
},{}),
Object.keys(fields).reduce((result, key) => {
result[key] = types.string;
return result;
},{})
);
//console.log("listQuery string: ", query(queryObj));
return {
query:gql`${query(queryObj)}`,
context: context
}
};