markhuot / craftql

A drop-in GraphQL server for Craft CMS
Other
320 stars 53 forks source link

How to use graphiqlFetchUrl setting (instead of default siteUrl)? #311

Closed Jones-S closed 5 years ago

Jones-S commented 5 years ago

Hi there

I read this https://github.com/markhuot/craftql/pull/135 PR, where @timkelty needed different siteUrl and graphqlUrl. This is exactly what I need, but I don't know how to set it.

Could someone tell me how to actually use this new setting? Sorry I am still new to craft and I don't always understand how things work...

Do I just have to add graphiqlFetchUrl inside my general config php file? (I tried it did not work).

I see that this is within the settings model: public $graphiqlFetchUrl = null; // defaults to siteUrl via CpController

But I don't know how to override.

Thank you for some help.

cheers

timkelty commented 5 years ago

@Jones-S you need a config/craftql.php file with something like:

<?php
return [
    'graphiqlFetchUrl' => 'yourdomain.com',
    'allowedOrigins' => [
        '*'
    ]
];
Jones-S commented 5 years ago

Hey thank you @timkelty for your super fast response. Just found out about that. The reason why it did not work the first time I tried, was because the $DEFAULT_SITE_URL was formatted like this: DEFAULT_SITE_URL="http://localdomain.test" instead of DEFAULT_SITE_URL="http://localdomain.test/".

This caused this error:

Screenshot 2019-08-28 at 14 19 44

So I had to change the the DEFAULT_SITE_URL... 🤷‍♂️. thanks anyway