Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit d8fb53d

Browse files
author
Josh Price
committed
Fix GraphiQL template bug which assumed /graphql endpoint
Template was taken from this example, which made incorrect assumptions about the endpoint which the GraphQL schema was mounted. https://github.com/graphql/graphiql/blob/544b383d9966db606c21888ea4e2af30c2310119/example/index.html#L93 Also updated to the latest GraphiQL version.
1 parent 0183fd2 commit d8fb53d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/graphql/plug/graphiql.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ defmodule GraphQL.Plug.GraphiQL do
1919

2020
@behaviour Plug
2121

22-
@graphiql_version "0.7.0"
22+
@graphiql_version "0.7.1"
2323
@graphiql_instructions """
2424
# Welcome to GraphQL Elixir!
2525
#

templates/graphiql.eex

+3-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ add "&raw" to the end of the URL within a browser.
8989

9090
// Defines a GraphQL fetcher using the fetch API.
9191
function graphQLFetcher(graphQLParams) {
92-
return fetch(window.location.origin + '/graphql', {
92+
// NOTE: This fetch URL should be relative to the current URL
93+
// This is so that the GraphQL Elixir Plug can be mounted anywhere
94+
return fetch('', {
9395
method: 'post',
9496
headers: {
9597
'Accept': 'application/json',

0 commit comments

Comments
 (0)