• Stars
    star
    112
  • Rank 311,252 (Top 7 %)
  • Language
    PHP
  • License
    GNU General Publi...
  • Created almost 5 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Makes WP GraphQL's authetication "just work". It does this by customizing the CORS headers.

WP GraphQL CORS

The primary purpose of this plugin is to make the WP GraphQL plugin authentication "just work". It does this by allowing you set the CORS headers that GraphQL will accept, which means that WordPress's default authentication cookies will be accepted.

This means that if a user is logged into WordPress, they will be able to see things like draft and private pages/posts via GraphQL.

Features

  • Allows WP-GraphQL to accept default WordPress cookies
  • Works across multiple domains (so you can have multiple frontends connected to one backend)
  • Allows you to filter out specific cookies for added security (perhaps you don't want to use this for WordPress authentication but do want to access other cookies)
  • Allows you to customize the GraphQL endpoint
  • Extends WP GraphQL to have a logout and login mutation
  • Allows you to filter out which cookies are allowed

Installation

  1. Requires WP GraphQL.
  2. Upload this plugin to WordPress.
  3. Config your GraphQL client (probably Apollo) to include credentials in requests. Generally this is a setting under httpLinkOptions and look to set credentials = "include".

Now if the browser is currently logged into WordPress, WP GraphQL will allow access to authenticated data.

Documentation

If all you want to do is allow draft, private and page previews to be viewed from the frontend, setting Send site credentials. and Add Site Address to "Access-Control-Allow-Origin" header to true will do this.

You'll also need to config your GraphQL client (probably Apollo) to include credentials in requests. Generally this is a setting under httpLinkOptions and look to set credentials = "include".

Logout Mutation

If enabled in the settings, WP GraphQL will have a new mutation available to allow a user to logout. This is useful if you want to build a "logout" button on a sites frontend.

mutation {
    logout(input: {clientMutationId = "anything unique"}){
        clientMutationId
        status
    }
}

Login Mutation

If enabled in the settings, WP GraphQL will have a new mutation available to allow a user to login.

mutation {
	loginWithCookies(input: {clientMutationId: "", login: "", password: ""}) {
        clientMutationId
        status
    }
}

More Repositories

1

fuxt

A complete Headless WordPress tech stack built on Nuxt.
Vue
219
star
2

vuehaus

Vue.js on top of WordPress
PHP
137
star
3

fuxt-backend

A theme that turns WordPress into a true GraphQL powered Headless CMS. Optimized for the fuxt frontend boilerplate.
PHP
100
star
4

best-practices

A running list of best practices learned from 10 years on the frontlines of a digital agency
42
star
5

lenis-scroll-snap

JavaScript
36
star
6

fuxt-shopify

Useful Shopify components built to work with the fuxt Nuxt boilerplate.
Vue
35
star
7

wordpress-theme-boilerplate

Funkhaus programming style guide and WordPress template theme.
PHP
28
star
8

fh-components

Reusable components for Vue + Vuehaus
Vue
18
star
9

Rest-Easy

Wordpress plugin to rest-ify your site with zero effort and powerful customization.
PHP
14
star
10

wp-shopify

A WordPress plugin to easily integrate Shopify into any site.
PHP
14
star
11

ql-search

An WPGraphQL extension that adds SearchWP's query functionality to the GraphQL server
PHP
13
star
12

fitToParent

A tool that will resize a DOM element to fit its parent container while maintaining original aspect ratio.
JavaScript
11
star
13

funkhaus-auto-seo

Automatically implement SEO best practices using the power of AI
PHP
10
star
14

zoomhaus

Smooth takeover image zoom effect.
JavaScript
5
star
15

wp-gql-gutenberg

PHP
4
star
16

funky-colors

A Wordpress plugin to detect a palette of colors from each image in the media library
PHP
4
star
17

can-vue

Canvas + Vue.js
Vue
3
star
18

wp-shopify-js

Client-side Vue plugin for wp-shopify
JavaScript
3
star
19

store

An e-commerce toolkit for WordPress
PHP
3
star
20

factory-archive

The Funkhaus component Factory - a proof of concept for an upcoming component marketplace
CSS
3
star
21

8baseDemo-frontend

Vue
3
star
22

netlify-deploy

Trigger a deploy to Netlify either automatically or with a button in the dashboard.
PHP
3
star
23

whenInView

jQuery plugin to listen for when elements enter and leave the window
JavaScript
3
star
24

scrollaxer

A parallax-y scrolling slideshow plugin for jQuery
JavaScript
2
star
25

social-pull

Wordpress plugin to easily import information from one or many social media accounts.
PHP
1
star
26

fh-footer

Self-updating slide-to-reveal footer in vanilla JS
JavaScript
1
star
27

focushaus

Pick image focal points and preview the results.
JavaScript
1
star
28

8baseDemo-backend

JavaScript
1
star
29

fh-deploy

Deploy files to a server via SFTP.
JavaScript
1
star
30

new-project-script

Node script to create a local install of a new site
JavaScript
1
star
31

CenterSlider.js

A barebones jQuery plugin for making slideshows that center.
HTML
1
star
32

roadblocker

jQuery plugin to manage when to display a roadblock overlay
JavaScript
1
star