Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kallefrombosnia/twill-graphql
twill-graphql provides GraphQL wrapper for Twill CMS
https://github.com/kallefrombosnia/twill-graphql
api graphql laravel php twill
Last synced: 3 months ago
JSON representation
twill-graphql provides GraphQL wrapper for Twill CMS
- Host: GitHub
- URL: https://github.com/kallefrombosnia/twill-graphql
- Owner: kallefrombosnia
- License: mit
- Created: 2022-02-06T00:34:03.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-04-24T12:59:19.000Z (over 1 year ago)
- Last Synced: 2024-04-08T02:16:10.287Z (7 months ago)
- Topics: api, graphql, laravel, php, twill
- Language: PHP
- Homepage:
- Size: 92.8 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
- awesome-twill - Twill GraphQL - Provides GraphQL wrapper for Twill CMS (Packages)
README
# Twill CMS GraphQL :telescope:
Twill GraphQL provides easy access to query-specific fields from Twill CMS modules and user-defined modules with GraphQL.
The project is heavily inspired by [twill-api](https://github.com/area17/twill-api)
### Documentation
Check the [documentation.](https://github.com/kallefrombosnia/twill-graphql/tree/master/docs)
### Technologies
This package uses [nuwave/lighthouse](https://github.com/nuwave/lighthouse) and [mll-lab/laravel-graphql-playground](https://github.com/mll-lab/laravel-graphql-playground) for providing easy access to models and playground UI for exploring server schemas and testing.
Big props to them and Twill developers for creating such amazing projects.
Per default graphql endpoint serves on `/graphql` and playground is available on `/graphql-playground`
### Install package
**From composer**
```sh
composer require kallefrombosnia/twill-graphql
```### Configuration
Deploy default graphql schema
```sh
$ php artisan twill:graphql:deploy
```Deploy `lighthouse` config
```sh
$ php artisan vendor:publish --tag=lighthouse-config
```> This is not hardcoded into our config since lighthouse is constantly changing their codebase
After deploying lighthouse config, find it in the `./config/lighthouse.php`
Find `namespaces` which should look like this.
```php
'namespaces' => [
'models' => ['App', 'App\\Models'],
'queries' => 'App\\GraphQL\\Queries',
'mutations' => 'App\\GraphQL\\Mutations',
'subscriptions' => 'App\\GraphQL\\Subscriptions',
'interfaces' => 'App\\GraphQL\\Interfaces',
'unions' => 'App\\GraphQL\\Unions',
'scalars' => 'App\\GraphQL\\Scalars',
'directives' => ['App\\GraphQL\\Directives'],
'validators' => ['App\\GraphQL\\Validators'],
],
```At the moment only config option needed for us is `models`
Change it like this to load default Twill modules into it (make sure you have Twill CMS installed).```php
'namespaces' => [
'models' => ['A17\\Twill\\Models', 'App', 'App\\Models'],
...
],
```This will autoload all package models first so make sure your Laravel models and Twill custom models are not named the same as Twill CMS modules.
Reserved: `Feature`, `Block`, `File`, `Media`, `Setting`, `Tag`, `User`.
And you are ready to go.
### Project roadmap
- [x] Create wrapper around Twill default models for relations
- [x] Add examples
- [x] Write tests
- [x] Create composer package (publish)
- [x] Create guards example
- [x] Create mutations
- [x] More tests
- [ ] Subscriptions
- [ ] Tests for subscribtions
- [ ] TBA### Query on Twill custom user models
For example, we have the `Category` model which is located in `app\Models`
By `lighthouse` configuration this model is also loaded.```php
// app/Models/Category.php