pageballoon / headstart

Decoupled GraphQL-driven content management using OctoberCMS
https://octobercms.com/plugin/nocio-headstart
MIT License
7 stars 2 forks source link

Error on graphql endpoint #9

Open creativeesprit opened 4 years ago

creativeesprit commented 4 years ago

Hi,

Thanks for your hard work on this plugin. Unfortunately, I ran into an error on the graphql endpoint on enabling the plugin

Type error: Return value of Nuwave\Lighthouse\Execution\BaseRequest::query() must be of the type string, null returned

The error is found at: plugins/nocio/headstart/vendor/nuwave/lighthouse/src/Execution/BaseRequest.php line 50

I'm running php 7.2.11 and OctomberCMS build 465

Appreciate any help you can provide!

frthjf commented 4 years ago

Hi @creativeesprit,

Thanks for reporting this! I think I've reproduced the error and will investigate.

I'll keep you posted.

frthjf commented 4 years ago

@creativeesprit I believe the issue is caused by a redirection from my-host.com/graphql to my-host.com/graphql/ with trailing /. This causes the query variable to be empty which in turn yields the error message. As a workaround, could you try pointing your GraphQL client to /graphql/ with the trailing / and see if that resolves the issue. I'll work on the fix that prevents the redirection.

frthjf commented 4 years ago

I've released a fix in version 1.2.3 that ensures that the URL contains a trailing slash when using the build-in GraphiQL client. Please re-open if that does not solve the problem.

austyuzhaninov commented 2 years ago

Hi! @frthjf I have same error after install OctoberCMS + Headstart plugin.

php 7.4.25 version OctoberCMS 2.1.20 Headstart 1.2.3

url http://localhost:8000/graphql Declaration of Nocio\Headstart\Classes\Schema::getPath($dirName = NULL) must be compatible with Cms\Classes\Theme::getPath(?string $dirName = NULL): string ~/plugins/nocio/headstart/classes/Schema.php line 17

When I set string type public function getPath(string $dirName = null): string { if (!$dirName) { $dirName = $this->getDirName(); } return Settings::getSchemaDirectory() . / . $dirName; } I got another error Declaration of Nocio\Headstart\Classes\Schema::getActiveThemeCode() must be compatible with Cms\Classes\Theme::getActiveThemeCode(): ?string ~/plugins/nocio/headstart/classes/Schema.php line 42

I also set string type public static function getActiveThemeCode(): string { return 'headstart'; } And now i have Return value of Nuwave\Lighthouse\Execution\BaseRequest::query() must be of the type string, null returned ~/plugins/nocio/headstart/vendor/nuwave/lighthouse/src/Execution/BaseRequest.php line 50

http://localhost:8000/backend/nocio/headstart/schema error Class 'Cms\Widgets\AssetList' not found ~/plugins/nocio/headstart/formwidgets/AssetList.php line 12

Among other things in backend menu API dropdown list have broken links (Schema, Components, Directives, Source, Test) lead to http://localhost:8000/backend/javascript:;

What am I doing wrong?

frthjf commented 2 years ago

Hi @austyuzhaninov,

Not entirely sure but it looks like this might be caused by the upgrade to October 2.0. I've never tested whether Headstart works with 2.0 and it might well be that some things changed enough to break it. I am afraid I don't have the time right now to upgrade Headstart to be compatible with October 2.0 (#10).

If you like to have a go with it, I am happy to invite you to the repository to upgrade the dependencies. Since I don't have the bandwidth to maintain Headstart at the minute, I'd be happy to open source it as well if anybody likes to maintain it. Not sure if you can get a refund if you purchased though 🤔

daftspunk commented 2 years ago

Hi @frthjf

This indeed looks to be caused by the different method signatures in v2.0. It should be a straight forward fix, but the issue will be keeping backwards support for v1.0 versions. This is now possible since v2.0 uses composer as its dependency manager.

Some steps to follow might be

Inside the new version's composer file, you can specify which core version is required. This example requires the latest stable version (2.1).

    "require": {
        "october/system": "^2.1",
        "composer/installers": "~1.0"
    }

This result is: users running OC1 will receive the current version and users running OC2 will get the latest. More details can be found here: https://octobercms.com/docs/help/publishing-packages#dependencies

I hope this helps! Also, feel free to send us an email if you require a developer license to maintain this plugin.

Best regards.

frthjf commented 2 years ago

Hi @daftspunk,

Thanks for that, that's very helpful! Will look into that as soon as possible. In the meantime, @austyuzhaninov if you have any bandwidth any help is welcome. As I said, would be happy to open source this so people can contribute.