Skip to content

Instantly share code, notes, and snippets.

View hsimah's full-sized avatar

hsimah

View GitHub Profile
<?php
/*
* This is an upsert mutation. It will create or update a cpt and a custom table holding additional data
*/
register_graphql_mutation( 'upsertPost', [
'inputFields' => array_merge(
PostObjectCreate::get_input_fields( $post_type ), // use default mutation inputs for this post type
[
'tutorialId' => [
@hsimah
hsimah / custom-join.php
Last active January 21, 2019 10:19
Use GraphQL query arguments where data is in custom table
<?php
add_filter( 'posts_clauses', function( $clauses, $query_object ) {
global $wpdb;
$user_id = get_current_user_id();
if ( ! array_key_exists('graphql_args', $query_object->query ) ) {
return $clauses;
}
switch ( $query_object->query['post_type'] ) {
case 'edgeuserquiz':
@hsimah
hsimah / wpgraphql-metabox.php
Last active December 8, 2018 04:12
WPGraphQL > Meta Box Custom Fields
<?
// Meta Box managed postmeta fields
// CPT
register_graphql_fields( 'Quiz', [
'quizType' => [
'type' => 'String',
'description' => __( 'Quiz type', 'wpgraphql-metabox' ),
'resolve' => function( $quiz_post ) {
<?php
use WPGraphQL\Data\DataSource;
class UserQuizType {
private static $entity = null;
/**
* Register UserQuiz fields
function Enter-Session {
[CmdletBinding()]
Param()
DynamicParam {
$ParameterName = 'ComputerName'
$Attribute = New-Object System.Management.Automation.ParameterAttribute
$Attributes = New-Object -Type System.Collections.ObjectModel.Collection[System.Attribute]
$Parameters = New-Object -Type System.Management.Automation.RuntimeDefinedParameterDictionary