Stuart Grimshaw Posted May 10 Posted May 10 (edited) Following on from the Laravel topic earlier this year, I'm trying to invoke the GraphQL class from my Laravel app and I'm getting the following error: [2024-05-10 10:35:05] dev.ERROR: LOCATION_UNKNOWN {"exception":"[object] (RuntimeException(code: 0): LOCATION_UNKNOWN at /Users/stuart/Projects/brfcs/brfcs/ips_a1ee4/system/Session/Session.php:61) Even the simple example in the other thread gives the same error, the main difference from February is I've updated to the latest version and installed the dev tools. Edited May 10 by Stuart Grimshaw Added link to thread.
Stuart Grimshaw Posted May 11 Author Posted May 11 This is the block of code that's throwing the error: if( class_exists( 'IPS\Dispatcher', FALSE ) ) { $location = ( \IPS\Dispatcher::hasInstance() ) ? mb_ucfirst( \IPS\Dispatcher::i()->controllerLocation ) : 'Front'; $classname = 'IPS\Session\\' . $location; } else { throw new \RuntimeException('LOCATION_UNKNOWN'); } that's a clip from Session.php. In my Laravel controller I'm callingt the GraphQL command as described in the documentation Here's a copy of the controller: <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Inertia\Inertia; class InvisionController extends Controller { /** * Returns a JSON string of the users account information in the response. * * @return \Inertia\Response */ public function show(Request $request) { $query = '{core{me}}'; $result = \IPS\Api\GraphQL::execute($query); // $result = \IPS\Member::loggedIn()->name; return Inertia::render('Invision', ['result' => $result]); } } Could it be related to the fact this controller is using Inertia to render it's view? The error though occurs before it gets to that point doesn't it, when it calls `GraphQL::execute()`
Daniel F Posted May 12 Posted May 12 You could literally just fire a proper request to the GraphQL endpoint instead of including the IPS framework and instead of utilizing it direct, using then the GraphQL class. G17 Media 1
Stuart Grimshaw Posted May 13 Author Posted May 13 Do I not need to auth the user with oauth to do that?
Stuart Grimshaw Posted May 14 Author Posted May 14 The reason I was asking about oauth is that I'm trying to integrate the Strapi based news section of our website with the forums so that our forum users can comment on articles. If they are already logged in to the forum, I don't want them to then have to log in again to leave a comment, or have the oauth journey ask them if they want to give permission for what is to them the same website. I'm thinking now that I might "just" have Strapi use the GraphQL API with an access key as a system user to create a new thread in a forum when it publishes an article, retreive the existing comments to display, but then redirect users to the actual thread to leave a comment. I don't like that approach, but we have a deadline and it would at least enable the feature for us, albeit with a clunky way of getting back to the article after you leave a comment. Is there a better way to acheive what I'm trying to do?
Solution Stuart Grimshaw Posted May 24 Author Solution Posted May 24 So, in the end I used resource owner creds and created a system user account on the forum, that way end users can stay logged in and I can get topics & responses via GraphQL without having to include the whole Invision framework.
Recommended Posts