Skip to content

Instantly share code, notes, and snippets.

@mlipscombe
mlipscombe / functions.php
Created May 28, 2019 00:50
Render Elementor-styled content in WP-GraphQL
add_action('graphql_register_types', function() {
$post_types = WPGraphQL::$allowed_post_types;
if (!empty($post_types) && is_array($post_types)) {
foreach($post_types as $post_type) {
$post_type_object = get_post_type_object($post_type);
register_graphql_field($post_type_object->graphql_single_name, 'styledContent', [
'type' => 'String',
'description' => __('The styled elementor content of the page', 'cottontailpress-headless'),
'resolve' => function($post) {
$content = '';
import debugFactory from 'debug';
import { GraphQLNonNull, parse, valueFromAST, astFromValue } from 'graphql';
const { omit } = require('graphile-build-pg');
const debug = debugFactory('graphile-build-pg');
export default (function PostGraphileNestedMutationPlugin(builder) {
builder.hook('build', build =>
build.extend(build, {
@mlipscombe
mlipscombe / postgraphile-tsv-plugin.js
Last active October 8, 2022 12:03
full text search plugin for postgraphile
const tsquery = require('pg-tsquery');
const TSVECTOR_TYPE_ID = 3614;
export const PostGraphileTSVPlugin = (builder) => {
builder.hook('inflection', (inflection, build) => {
return build.extend(inflection, {
fullTextScalarTypeName() {
return 'FullText';
},