We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import Debug from 'debug'; import gql from 'graphql-tag'; const debug = Debug('deeplinks:gql:query'); const log = debug.extend('log'); const error = debug.extend('error'); // Force enable this file errors output const namespaces = Debug.disable(); Debug.enable(`${namespaces ? `${namespaces},` : ``}${error.namespace}`); const fieldsInputs = (tableName): IGenerateQueryFieldTypes => ({ 'distinct_on': `[${tableName}_select_column!]`, 'limit': `Int`, 'offset': `Int`, 'order_by': `[${tableName}_order_by!]`, 'where': `${tableName}_bool_exp!`, }); export interface IGenerateQueryDataOptions { tableName: string; operation?: 'query' | 'subscription'; queryName?: string; returning?: string; variables?: any; // TODO } export interface IGenerateQueryDataBuilder { (alias: string, index: number): IGenerateQueryDataResult } export interface IGenerateQueryFieldTypes { [field: string]: string; } export interface IGenerateQueryDataResult extends IGenerateQueryDataOptions { resultReturning: string; fields: string[]; fieldTypes: IGenerateQueryFieldTypes; defs: string[]; args: string[]; alias: string; index: number; resultAlias: string; resultVariables: any; } export const generateQueryData = ({ tableName, operation = 'query', queryName = `${tableName}`, returning = `id`, variables, }: IGenerateQueryDataOptions): IGenerateQueryDataBuilder => { log('generateQuery', { tableName, operation, queryName, returning, variables }); const fields = ['distinct_on', 'limit', 'offset', 'order_by', 'where']; const fieldTypes = fieldsInputs(tableName); return (alias: string, index: number): IGenerateQueryDataResult => { log('generateQueryBuilder', { tableName, operation, queryName, returning, variables, alias, index }); const defs = []; const args = []; for (let f = 0; f < fields.length; f++) { const field = fields[f]; defs.push(`$${field + index}: ${fieldTypes[field]}`); args.push(`${field}: $${field}${index}`); } const resultAlias = `${alias}${typeof(index) === 'number' ? index : ''}`; const resultVariables = {}; for (const v in variables) { if (Object.prototype.hasOwnProperty.call(variables, v)) { const variable = variables[v]; resultVariables[v + index] = variable; } } const result = { tableName, operation, queryName, returning, variables, resultReturning: returning, fields, fieldTypes, index, defs, args, alias, resultAlias, resultVariables, }; log('generateQueryResult', result); return result }; };
Translate this code to python and put it into query.py file.
The text was updated successfully, but these errors were encountered:
Merge pull request #1 from deep-foundation/main
19341b9
merge
Successfully merging a pull request may close this issue.
Translate this code to python and put it into query.py file.
The text was updated successfully, but these errors were encountered: