How to use the ast-types.builders.objectExpression function in ast-types

To help you get started, we’ve selected a few ast-types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rexxars / sql-to-graphql / steps / generate-types.js View on Github external
}

            values.push(b.property(
                'init',
                b.literal(enumKey),
                b.objectExpression([
                    b.property('init', b.identifier('value'), b.literal(enumValue.value)),
                    generateDescription(enumValue.description)
                ])
            ));
        }

        var typeDeclaration = b.objectExpression([
            b.property('init', b.identifier('name'), b.literal(model.name + capitalize(field.name))),
            generateDescription(field.description),
            b.property('init', b.identifier('values'), b.objectExpression(values))
        ]);

        return b.newExpression(
            b.identifier('GraphQLEnumType'),
            [typeDeclaration]
        );
    }
}
github rexxars / sql-to-graphql / steps / ast-builders / object.js View on Github external
function buildObject(obj) {
    var fields = [], key;
    for (key in obj) {
        fields.push(b.property('init', b.literal(key), castValue(obj[key])));
    }

    return b.objectExpression(fields);
}
github paeckchen / paeckchen / packages / paeckchen-core / src / modules.ts View on Github external
function wrapExternalModule(modulePath: string, context: PaeckchenContext): Promise {
  const external = context.config.externals[modulePath] === false
    ? b.objectExpression([])
    : b.identifier(context.config.externals[modulePath] as string);
  return Promise.resolve(b.program([
    b.expressionStatement(
      b.assignmentExpression(
        '=',
        b.memberExpression(
          b.identifier('module'),
          b.identifier('exports'),
          false
        ),
        external
      )
    )
  ]));
}
github rexxars / sql-to-graphql / steps / ast-builders / schema.js View on Github external
}

    return buildVar('schema',
        b.newExpression(
            b.identifier('GraphQLSchema'),
            [b.objectExpression([
                b.property(
                    'init',
                    b.identifier('query'),
                    b.newExpression(
                        b.identifier('GraphQLObjectType'),
                        [b.objectExpression([
                            b.property('init', b.identifier('name'), b.literal('RootQueryType')),
                            b.property('init', b.identifier('fields'), buildFieldWrapperFunction(
                                'RootQuery',
                                b.objectExpression(queryFields),
                                opts
                            ))
                        ])]
                    )
                )
            ])]
        )
    );
};
github rexxars / sql-to-graphql / steps / ast-builders / resolve-map.js View on Github external
function buildConnectionsVar(opts) {
    if (!opts.relay) {
        return [];
    }

    return [buildVariable('connections', b.objectExpression([]), opts.es6)];
}
github rexxars / sql-to-graphql / steps / generate-types.js View on Github external
fields.push(generateListReferenceField(ref));
        });

        var interfaces = opts.relay && b.property(
            'init',
            b.identifier('interfaces'),
            b.arrayExpression([b.identifier('nodeInterface')])
        );

        var typeDeclaration = b.objectExpression([
            b.property('init', b.identifier('name'), b.literal(name)),
            generateDescription(model.description),
            b.property(
                'init',
                b.identifier('fields'),
                buildFieldWrapperFunction(name, b.objectExpression(fields), opts)
            )
        ].concat(interfaces || []));

        return {
            ast: buildVar(
                name + 'Type',
                b.newExpression(
                    b.identifier('GraphQLObjectType'),
                    [typeDeclaration]
                ),
                opts.es6
            )
        };
    }
github interfaced / zombiebox / scripts / generate-config-docs.js View on Github external
_renderJsExports(classes) {
		return escodegen.generate(b.assignmentExpression(
			'=',
			b.memberExpression(
				b.identifier('module'),
				b.identifier('exports')
			),
			b.objectExpression(
				classes.map((object) => b.property(
					'init',
					b.identifier(this._getJsInterfaceName(object['$id'])),
					b.identifier(this._getJsInterfaceName(object['$id']))
				))
			)
		));
	}
}
github rexxars / sql-to-graphql / steps / generate-types.js View on Github external
if (!enumKey.match(enumRegex)) {
                enumKey = 'ENUM_' + enumKey;
            }

            values.push(b.property(
                'init',
                b.literal(enumKey),
                b.objectExpression([
                    b.property('init', b.identifier('value'), b.literal(enumValue.value)),
                    generateDescription(enumValue.description)
                ])
            ));
        }

        var typeDeclaration = b.objectExpression([
            b.property('init', b.identifier('name'), b.literal(model.name + capitalize(field.name))),
            generateDescription(field.description),
            b.property('init', b.identifier('values'), b.objectExpression(values))
        ]);

        return b.newExpression(
            b.identifier('GraphQLEnumType'),
            [typeDeclaration]
        );
    }
}