├── .github ├── ISSUE_TEMPLATE │ └── issue.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── LICENSE ├── README.md ├── docker-compose.yml ├── docs ├── api-directives.md ├── api-resolvers.md ├── assets │ └── tutorial │ │ ├── flow.png │ │ ├── model.png │ │ └── playground.png ├── basics-fields.md ├── basics-schema.md ├── basics-types.md ├── getting-started-configuration.md ├── getting-started-installation.md ├── getting-started-tutorial.md ├── guides-auth.md ├── guides-plugin-development.md ├── guides-relationships.md ├── guides-relay.md ├── guides-schema-organisation.md └── guides-validation.md ├── logo.png └── website ├── core ├── Button.js └── Footer.js ├── i18n └── en.json ├── package-lock.json ├── package.json ├── pages └── en │ ├── index.js │ ├── resources.js │ ├── users.js │ └── versions.js ├── sidebars.json ├── siteConfig.js ├── static ├── css │ └── custom.css └── img │ ├── bg-hero.png │ ├── favicon.png │ ├── logo.svg │ └── users │ ├── entryninja.png │ ├── mll.svg │ ├── nuwave.png │ └── traimmu.jpg ├── tailwind.js ├── tailwind └── styles.css ├── users.js ├── versioned_docs ├── version-2.0 │ ├── directives-args.md │ ├── directives-fields.md │ ├── directives-nodes.md │ ├── getting-started-config.md │ ├── getting-started-installation.md │ ├── getting-started-introduction.md │ ├── schema-scalars.md │ └── schema-schema.md ├── version-2.1 │ ├── directives-crud.md │ ├── directives-laravel.md │ ├── directives-misc.md │ ├── directives-queries.md │ ├── directives-relationships.md │ ├── directives-relay.md │ ├── directives-schema.md │ ├── directives-security.md │ ├── getting-started-config.md │ ├── getting-started-installation.md │ └── schema-extending.md ├── version-2.2 │ ├── api-directives.md │ ├── api-resolvers.md │ ├── basics-fields.md │ ├── basics-schema.md │ ├── basics-types.md │ ├── getting-started-configuration.md │ ├── getting-started-installation.md │ ├── guides-auth.md │ ├── guides-relationships.md │ ├── guides-relay.md │ ├── guides-schema-organisation.md │ └── guides-validation.md ├── version-2.3 │ ├── api-directives.md │ ├── api-resolvers.md │ ├── basics-fields.md │ ├── basics-types.md │ ├── getting-started-configuration.md │ ├── getting-started-installation.md │ ├── guides-plugin-development.md │ ├── guides-relationships.md │ ├── guides-relay.md │ └── guides-schema-organisation.md ├── version-2.4 │ ├── api-directives.md │ ├── basics-fields.md │ └── getting-started-configuration.md ├── version-2.5 │ ├── api-directives.md │ ├── api-resolvers.md │ ├── basics-types.md │ ├── getting-started-configuration.md │ ├── guides-auth.md │ ├── guides-plugin-development.md │ ├── guides-relationships.md │ └── guides-schema-organisation.md └── version-2.6 │ ├── api-directives.md │ ├── getting-started-configuration.md │ ├── getting-started-installation.md │ └── getting-started-tutorial.md ├── versioned_sidebars ├── version-2.0-sidebars.json ├── version-2.1-sidebars.json ├── version-2.2-sidebars.json ├── version-2.3-sidebars.json └── version-2.6-sidebars.json └── versions.json /.github/ISSUE_TEMPLATE/issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Issue 3 | about: Submit an issue with the docs 4 | 5 | --- 6 | 7 | **Related Issue/PR from the main repo** 8 | 9 | Link to related Issue/PR this PR corresponds to 10 | 11 | **Lighthouse Version** 12 | 13 | Which version of Lighthouse does this apply to? 14 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | **Related Issue/PR from the main repo** 2 | 3 | Link to related Issue/PR this PR corresponds to 4 | 5 | **Lighthouse Version** 6 | 7 | Which version of Lighthouse does this apply to? 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | node_modules 4 | 5 | lib/core/metadata.js 6 | lib/core/MetadataBlog.js 7 | 8 | website/translated_docs 9 | website/build/ 10 | website/yarn.lock 11 | website/node_modules 12 | website/i18n/* 13 | !website/i18n/en.json 14 | 15 | # PHPStorm 16 | .idea 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Christopher Moore 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The docs for Lighthouse have moved to the main repository https://github.com/nuwave/lighthouse 2 | 3 | 4 | 5 | # Lighthouse Docs 6 | 7 | [![GitHub license](https://img.shields.io/github/license/nuwave/lighthouse.svg)](https://github.com/nuwave/lighthouse/blob/master/LICENSE) 8 | [![Get on Slack](https://img.shields.io/badge/slack-join-orange.svg)](https://join.slack.com/t/lighthouse-php/shared_invite/enQtMzc1NzQwNTUxMjk3LWI1ZDQ1YWM1NmM2MmQ0NTU0NGNjZWFkMTJhY2VjMDAwZmMyZDFlZTc1Mjc3ZGY0MWM1Y2Q5MWNjYmJmYWJkYmU) 9 | 10 | These are the docs for Lighthouse, a GraphQL server for Laravel. 11 | 12 | **For more information, head over [to the main project](https://github.com/nuwave/lighthouse)** 13 | **or take a look at the [documentation website](https://lighthouse-php.com/)** 14 | 15 | The docs are built with [Docusaurus](https://docusaurus.io/). 16 | 17 | ## Contribute to the docs 18 | 19 | 1. Fork the project 20 | 1. Create a new branch 21 | 1. Make changes to the code 22 | 1. Commit with a concise title line and a few more lines detailing the change 23 | 1. Open a PR detailing your changes 24 | 25 | ### Setup 26 | 27 | You can build and view the docs locally. 28 | You either need `yarn`/`npm` or `docker` installed. 29 | 30 | First, go ahead and `git clone` this repo (or your fork) and `cd` in the project root. 31 | 32 | #### Docker 33 | 34 | docker-compose up -d 35 | 36 | #### Node 37 | 38 | cd website 39 | yarn 40 | yarn run start 41 | 42 | ### Tag a new version 43 | 44 | Only feature releases get a new docs version, so we do not tag the docs as `1.2.3`, just `1.2` does suffice. 45 | 46 | yarn run version x.y 47 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "2" 2 | 3 | services: 4 | docs: 5 | image: node:alpine 6 | user: "node" 7 | working_dir: /home/node/app/website 8 | environment: 9 | # Necessary if the mount comes from a windows filesystem 10 | - CHOKIDAR_USEPOLLING=true 11 | ports: 12 | - 80:3000 13 | volumes: 14 | - ./:/home/node/app 15 | command: sh -c "yarn && yarn start" 16 | -------------------------------------------------------------------------------- /docs/api-resolvers.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: resolvers 3 | title: Resolvers 4 | --- 5 | 6 | ## Resolver function signature 7 | 8 | Resolvers are always called with the same 4 arguments: 9 | 10 | ```php 11 | 'Bob']` 28 | 3. `GraphQLContext $context`: Arbitrary data that is shared between all fields of a single query. 29 | Lighthouse passes in an instance of `Nuwave\Lighthouse\Schema\Context` by default. 30 | 4. `ResolveInfo $resolveInfo`: Information about the query itself, 31 | such as the execution state, the field name, path to the field from the root, and more. 32 | 33 | ## Complexity function signature 34 | 35 | The complexity function is used to calculate a query complexity score for a field. 36 | You can define your own complexity function with the [@complexity](directives#complexity) directive. 37 | 38 | ```php 39 | 'Bob']` 48 | 49 | Read more about query complexity in the [webonyx/graphql-php docs]([Read More](http://webonyx.github.io/graphql-php/security/#query-complexity-analysis)) 50 | -------------------------------------------------------------------------------- /docs/assets/tutorial/flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nuwave/lighthouse-docs/a2ca6db8ce910f2575cf0790ebd7a3c5e694748a/docs/assets/tutorial/flow.png -------------------------------------------------------------------------------- /docs/assets/tutorial/model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nuwave/lighthouse-docs/a2ca6db8ce910f2575cf0790ebd7a3c5e694748a/docs/assets/tutorial/model.png -------------------------------------------------------------------------------- /docs/assets/tutorial/playground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nuwave/lighthouse-docs/a2ca6db8ce910f2575cf0790ebd7a3c5e694748a/docs/assets/tutorial/playground.png -------------------------------------------------------------------------------- /docs/basics-fields.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: fields 3 | title: Fields 4 | --- 5 | 6 | To fetch data from your GraphQL endpoint, you need to define resolvers for your fields. 7 | Lighthouse makes this easy by providing easy to use, pre-built resolvers that work 8 | great together with your Eloquent models. 9 | 10 | ## Hello World! 11 | 12 | As is the tradition of our people, this section will teach you how to say "hello world!" through Lighthouse. 13 | The following schema defines a simple field called `hello` that returns a `String`. 14 | 15 | ```graphql 16 | type Query { 17 | hello: String! 18 | } 19 | ``` 20 | 21 | You need to implement the actual resolver next. Lighthouse looks for a class with the capitalized name of the 22 | field in `App\Http\GraphQL\Queries` and calls its `resolve` function. 23 | 24 | ```php 25 | first(); 292 | } 293 | } 294 | ``` 295 | 296 | The easiest way to create such a class is to use the built in artisan commands 297 | `lighthouse:query` and `lighthouse:mutation`. They both take a single argument: 298 | the name of the field you want to generate. 299 | 300 | For example, this is how you generate a class for the field `latestPost`: 301 | 302 | php artisan lighthouse:query LatestPost 303 | 304 | If you need to implement custom resolvers for fields that are not on one of the 305 | root types `Query` or `Mutation`, you can use the [@field](directives#field) directive. 306 | -------------------------------------------------------------------------------- /docs/basics-schema.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: schema 3 | title: Schema 4 | --- 5 | 6 | A schema defines the capabilities of a GraphQL server. 7 | Much like a database schema, it describes the structure and the types your API can return. 8 | 9 | ## Types 10 | 11 | Types are the primary building blocks of a GraphQL schema. 12 | They define the capabilities of your API and the kind of data you can get from it. 13 | 14 | ```graphql 15 | type User { 16 | id: ID! 17 | name: String! 18 | email: String! 19 | created_at: String! 20 | updated_at: String 21 | } 22 | ``` 23 | 24 | ## Queries 25 | 26 | Every GraphQL schema must have a `Query` type which contains the queries your API offers. 27 | Think of queries as REST resources which can take arguments and return a fixed result. 28 | 29 | ```graphql 30 | type Query { 31 | me: User 32 | users: [User!]! 33 | userById(id: ID): User 34 | } 35 | ``` 36 | 37 | ## Mutations 38 | 39 | There is another special type called `Mutation`. 40 | It works similar to the `Query` type, but it exposes operations that are 41 | allowed to change data on the server. 42 | 43 | ```graphql 44 | type Mutation { 45 | createUser(name: String!, email: String!, password: String!): User 46 | updateUser(id: ID, email: String, password: String): User 47 | deleteUser(id: ID): User 48 | } 49 | ``` 50 | -------------------------------------------------------------------------------- /docs/basics-types.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: types 3 | title: Types 4 | --- 5 | 6 | A GraphQL schema is made out of types. This section describes the different set of types 7 | and how they can be defined to work with Lighthouse. For a more in-depth reference about types, 8 | look into the [GraphQL documentation](https://graphql.org/learn/schema/) 9 | 10 | ## Object Type 11 | 12 | Object types define the resources of your API and are closely related to Eloquent models. 13 | They must have a unique name and have a set of fields. 14 | 15 | ```graphql 16 | type User { 17 | id: ID! 18 | name: String! 19 | email: String! 20 | created_at: String! 21 | updated_at: String 22 | } 23 | 24 | type Query { 25 | users: [User!]! 26 | user(id: ID!): User 27 | } 28 | ``` 29 | 30 | ## Scalar 31 | 32 | Scalar types are the most basic elements of a GraphQL schema. There are a 33 | few built in scalars, such as `String` or `Int`. 34 | 35 | Lighthouse provides some scalars that work well with Laravel out of the box, you can find 36 | them in the [default schema](installation#publish-the-default-schema). 37 | 38 | Define your own scalar types by running `php artisan lighthouse:scalar ` 39 | and including it in your schema. Lighthouse will look for Scalar types in a configurable 40 | default namespace. 41 | 42 | ```graphql 43 | scalar ZipCode 44 | 45 | type User { 46 | zipCode: ZipCode 47 | } 48 | ``` 49 | 50 | You can also use third-party scalars, such as those provided by [mll-lab/graphql-php-scalars](https://github.com/mll-lab/graphql-php-scalars). 51 | Just `composer require` your package of choice and add a scalar definition to your schema. 52 | Use the [@scalar](directives#scalar) directive to point to any fully qualified class name: 53 | 54 | ```graphql 55 | scalar Email @scalar(class: "MLL\\GraphQLScalars\\Email") 56 | ``` 57 | 58 | [Learn how to implement your own scalar.](https://webonyx.github.io/graphql-php/type-system/scalar-types/) 59 | 60 | ## Enum 61 | 62 | Enums are types with a restricted set of values (similar to `enum` found in database migrations). 63 | They are defined as a list of `UPPERCASE` string keys. You can define the actual values through 64 | the [@enum](directives#enum) directive. 65 | 66 | 67 | ```graphql 68 | enum EmploymentStatus { 69 | INTERN @enum(value: 0) 70 | EMPLOYEE @enum(value: 1) 71 | TERMINATED @enum(value: 2) 72 | } 73 | ``` 74 | 75 | Now we can use the enum as part of our schema. 76 | 77 | ```graphql 78 | type Employee { 79 | id: ID! 80 | name: String 81 | status: EmploymentStatus! 82 | } 83 | 84 | type Query { 85 | employees: [Employee!]! @all 86 | } 87 | ``` 88 | 89 | In this example, the underlying values are actually integers. When the models are retrieved from 90 | the database, the mapping is applied and the integers are converted to the defined string keys. 91 | 92 | ```php 93 | return [ 94 | ['name' => 'Hans', 'status' => 0], 95 | ['name' => 'Pamela', 'status' => 1], 96 | ['name' => 'Gerhard', 'status' => 2], 97 | ]; 98 | ``` 99 | 100 | Queries now return meaningful names instead of magic numbers. 101 | 102 | ```graphql 103 | { 104 | employees { 105 | name 106 | status 107 | } 108 | } 109 | ``` 110 | 111 | ```json 112 | { 113 | "data": { 114 | "employees": [ 115 | {"name": "Hans", "status": "INTERN"}, 116 | {"name": "Pamela", "status": "EMPLOYEE"}, 117 | {"name": "Gerhard", "status": "TERMINATED"} 118 | ] 119 | } 120 | } 121 | ``` 122 | 123 | If the internal value of the enum is the same as the field name, `@enum` can be omitted: 124 | 125 | ```graphql 126 | enum Role { 127 | ADMIN 128 | } 129 | ``` 130 | 131 | The PHP internal value of the field `ADMIN` will be `string('ADMIN')`. 132 | 133 | ## Input 134 | 135 | Input types can be used to describe complex objects for for field arguments. 136 | Beware that while they look similar to Object Types, they behave differently: 137 | The fields of an Input Type are treated similar to arguments. 138 | 139 | ```graphql 140 | input CreateUserInput { 141 | name: String! 142 | email: String 143 | } 144 | 145 | type User { 146 | id: ID! 147 | name: String! 148 | email: String 149 | } 150 | 151 | type Mutation { 152 | createUser(input: CreateUserInput!): User 153 | } 154 | ``` 155 | 156 | ## Interface 157 | 158 | The GraphQL `interface` type is similar to a PHP `Interface`. 159 | It defines a set of common fields that all implementing types must also provide. 160 | A common use-case for interfaces with a Laravel project would be polymorphic relationships. 161 | 162 | ```graphql 163 | interface Named { 164 | name: String! 165 | } 166 | ``` 167 | 168 | Object types can implement that interface, given that they provide all its fields. 169 | 170 | ```graphql 171 | type User implements Named { 172 | id: ID! 173 | name: String! 174 | } 175 | ``` 176 | 177 | The following definition would be invalid. 178 | 179 | ```graphql 180 | type User implements Named { 181 | id: ID! 182 | } 183 | ``` 184 | 185 | Interfaces need a way of determining which concrete Object Type is returned by a 186 | particular query. Lighthouse provides a default type resolver that works by calling 187 | `class_basename($value)` on the value returned by the resolver. 188 | 189 | You can also provide a custom type resolver. Run `php artisan lighthouse:interface ` to create 190 | a custom interface class. It is automatically put in the default namespace where Lighthouse can discover it by itself. 191 | 192 | Read more about them in the [GraphQL Reference](https://graphql.org/learn/schema/#interfaces) and the 193 | [docs for graphql-php](http://webonyx.github.io/graphql-php/type-system/interfaces/) 194 | 195 | ## Union 196 | 197 | A Union is an abstract type that simply enumerates other Object Types. 198 | They are similar to interfaces in that they can return different types, but they can not 199 | have fields defined. 200 | 201 | ```graphql 202 | union Person 203 | = User 204 | | Employee 205 | 206 | type User { 207 | id: ID! 208 | } 209 | 210 | type Employee { 211 | employeeId: ID! 212 | } 213 | ``` 214 | 215 | Just like Interfaces, you need a way to determine the concrete Object Type for a Union, 216 | based on the resolved value. If the default type resolver does not work for you, define your 217 | own using `php artisan lighthouse:union `. 218 | It is automatically put in the default namespace where Lighthouse can discover it by itself. 219 | 220 | Read more about them in the [GraphQL Reference](https://graphql.org/learn/schema/#union-types) and the 221 | [docs for graphql-php](http://webonyx.github.io/graphql-php/type-system/unions/) 222 | -------------------------------------------------------------------------------- /docs/getting-started-installation.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: installation 3 | title: Installation 4 | --- 5 | 6 | ## Install via composer 7 | 8 | ```bash 9 | $ composer require nuwave/lighthouse 10 | ``` 11 | 12 | ## Publish the default schema 13 | 14 | Lighthouse includes a default schema to get you going right away. Publish 15 | it using the following artisan command: 16 | 17 | ```bash 18 | $ php artisan vendor:publish --provider="Nuwave\Lighthouse\Providers\LighthouseServiceProvider" --tag=schema 19 | ``` 20 | 21 | Learn more about how a GraphQL schema works by reading up on the [schema basics](schema) 22 | 23 | ## Use GraphQL DevTools 24 | 25 | Lighthouse does not include additional GraphQL tooling, such as the GraphiQL editor. 26 | To integrate a web UI to query your GraphQL endpoint with your Laravel installation, we recommend 27 | installing [GraphQL Playground](https://github.com/mll-lab/laravel-graphql-playground) 28 | 29 | ```bash 30 | $ composer require mll-lab/laravel-graphql-playground 31 | ``` 32 | 33 | You can also use any external client with Lighthouse, make sure to point it to the URL defined in 34 | the config. Per default, the endpoint lives at `/graphql` 35 | 36 | ## Using the Facade 37 | 38 | If you want to use the GraphQL facade, add it to your `config/app.php` file 39 | 40 | ```php 41 | 'aliases' => [ 42 | // ... 43 | 'GraphQL' => Nuwave\Lighthouse\Support\Facades\GraphQLFacade::class, 44 | ] 45 | ``` 46 | -------------------------------------------------------------------------------- /docs/guides-auth.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: auth 3 | title: Authentication & Authorization 4 | --- 5 | 6 | ## Authentication 7 | 8 | ### Get the current user 9 | 10 | Lighthouse provides a really simple way to fetch the information of the currently authenticated user. 11 | Just add a field that returns your `User` type and decorate it with the [@auth](directives#auth) directive. 12 | 13 | ```graphql 14 | type Query { 15 | me: User @auth 16 | } 17 | ``` 18 | 19 | Sending the following query will return the authenticated user's info 20 | or `null` if the request is not authenticated. 21 | 22 | ```graphql 23 | query Me { 24 | me { 25 | name 26 | email 27 | } 28 | } 29 | ``` 30 | 31 | ## Authorization 32 | 33 | ### Restrict access to fields 34 | 35 | Lighthouse allows you to restrict field operations to a certain group of users. 36 | Use the [@can](directives#can) directive to leverage [Laravel Policies](https://laravel.com/docs/5.6/authorization) for authorization. 37 | 38 | ### Apply auth middleware 39 | 40 | Lighthouse allows you to configure global middleware that is run for every 41 | request to your endpoint, but also define it on a per-field basis. 42 | 43 | Use the [@middleware](directives#middleware) directive to apply Laravel middleware, 44 | such as the `auth` middleware, to selected fields of your GraphQL endpoint. 45 | 46 | ```graphql 47 | type Query { 48 | users: [User] @middleware(checks: ["auth:api", "custom"]) 49 | } 50 | ``` 51 | 52 | If you need to apply middleware to a group of fields, you can put [@middleware](directives#middleware) on an Object type. 53 | 54 | ```graphql 55 | extend type Query @group(middleware: ["auth:admin"]){ 56 | adminInfo: Secrets 57 | nukeCodes: [NukeCode!]! 58 | } 59 | ``` 60 | -------------------------------------------------------------------------------- /docs/guides-plugin-development.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: plugin-development 3 | title: Plugin Development 4 | --- 5 | 6 | Lighthouse is able to be extended in a lot of places. Plugin developers 7 | may utilize this to offer users extra functionality that is not available in the core. 8 | 9 | ## Guidelines 10 | 11 | - Try not to change core behaviour. If you really have to, make it really explicit. 12 | - Consider improving the extensibility of Lighthouse with a PR instead of doing workarounds. 13 | - Add your plugin to the Resources page once it is done. 14 | 15 |
16 | 17 | ## Add schema definitions 18 | 19 | You might want to provide some additional types to the schema. The preferred way to 20 | do this is to listen for the `BuildingAST` event. It is sent before Lighthouse parses 21 | the schema string. 22 | 23 | Check out [the test suite](https://github.com/nuwave/lighthouse/tree/master/tests/Integration/Events/BuildingASTTest.php) 24 | for an example of how this works. 25 | -------------------------------------------------------------------------------- /docs/guides-relationships.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: relationships 3 | title: Eloquent Relationships 4 | --- 5 | 6 | Eloquent relationships can be accessed just like any other properties. 7 | This makes it super easy to use in your schema. 8 | 9 | Suppose you have defined the following model: 10 | 11 | ```php 12 | hasMany(Comment::class); 25 | } 26 | 27 | public function author(): BelongsTo 28 | { 29 | return $this->belongsTo(User::class); 30 | } 31 | } 32 | ``` 33 | 34 | Just add fields to your type that are named just like the relationships: 35 | 36 | ```graphql 37 | type Post { 38 | author: User 39 | comments: [Comment!] 40 | } 41 | ``` 42 | 43 | This approach is fine if performance is not super critical or if you only fetch a single post. 44 | However, as your queries become larger and more complex, you might want to optimise performance. 45 | 46 | ## Defining Relationships 47 | 48 | Just like in Laravel, you can define [Eloquent Relationships](https://laravel.com/docs/eloquent-relationships) in your schema. 49 | Lighthouse has got you covered with specialized directives that optimize the Queries for you. 50 | 51 | Suppose you want to load a list of posts and associated comments. When you tell 52 | Lighthouse about the relationship, it automatically eager loads the comments when you need them. 53 | 54 | ### One To One 55 | 56 | Use the [@hasOne](directives#hasOne) directive to define a [one-to-one relationship](https://laravel.com/docs/eloquent-relationships#one-to-one) 57 | between two types in your schema. 58 | 59 | ```graphql 60 | type User { 61 | phone: Phone @hasOne 62 | } 63 | ``` 64 | 65 | The inverse can be defined through the [@belongsTo](directives#belongsTo) directive. 66 | 67 | ```graphql 68 | type Phone { 69 | user: User @belongsTo 70 | } 71 | ``` 72 | 73 | ### One To Many 74 | 75 | Use the [@hasMany](directives#hasMany) directive to define a [one-to-many relationship](https://laravel.com/docs/eloquent-relationships#one-to-many). 76 | 77 | ```graphql 78 | type Post { 79 | comments: [Comment!]! @hasMany 80 | } 81 | ``` 82 | 83 | Again, the inverse is defined with the [@belongsTo](directives#belongsTo) directive. 84 | 85 | ```graphql 86 | type Comment { 87 | post: Post! @belongsTo 88 | } 89 | ``` 90 | 91 | ### Many To Many 92 | 93 | While [many-to-many relationships](https://laravel.com/docs/5.7/eloquent-relationships#many-to-many) 94 | are a bit more work to set up in Laravel, defining them in Lighthouse is a breeze. 95 | Use the [@belongsToMany](directives#belongsToMany) directive to define it. 96 | 97 | ```graphql 98 | type User { 99 | roles: [Role!]! @belongsToMany 100 | } 101 | ``` 102 | 103 | The inverse works the same. 104 | 105 | ```graphql 106 | type Role { 107 | users: [User!]! @belongsToMany 108 | } 109 | ``` 110 | 111 | ## Renaming Relations 112 | 113 | When you define a relation, Lighthouse assumes that the field and the relationship 114 | method have the same name. If you need to name your field differently, you have to 115 | specify the name of the method. 116 | 117 | ``` 118 | type Post { 119 | author: User! @belongsTo(relation: "user") 120 | } 121 | ``` 122 | 123 | This would work for the following model: 124 | 125 | ```php 126 | belongsTo(User::class); 138 | } 139 | } 140 | ``` 141 | -------------------------------------------------------------------------------- /docs/guides-relay.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: relay 3 | title: Relay 4 | --- 5 | 6 | ## Cursor Connection 7 | 8 | Relay requires a particular kind of pagination which is the [Cursor Connection](https://facebook.github.io/relay/graphql/connections.htm) 9 | To get a relay-compatible connection on a root query field, use the [@paginate](directives#paginate) 10 | directive with the pagination type `connection`. 11 | 12 | ```graphql 13 | type Query { 14 | users: [User] @paginate(type: "connection") 15 | } 16 | ``` 17 | 18 | This automatically converts the type definition into a relay connection and constructs 19 | the appropriate queries via the underlying Eloquent model. 20 | Connections can also be used for sub-fields of a type, given they are defined as a HasMany-Relationship 21 | in Eloquent. Use the [@hasMany](directives#hasMany) directive. 22 | 23 | ```graphql 24 | type User { 25 | name: String 26 | posts: [Post] @hasMany(type: "connection") 27 | } 28 | ``` 29 | 30 | ## Global Object Identification 31 | 32 | // TODO write out this section, accepting PR's 33 | 34 | [Global Object Identification](https://facebook.github.io/relay/graphql/objectidentification.htm) 35 | 36 | [@model](directives#model) 37 | 38 | [@globalId](directives#globalid) 39 | 40 | ## Mutations 41 | 42 | // TODO write something about how Mutations must always take InputObjects and how flattening helps achieve that. 43 | -------------------------------------------------------------------------------- /docs/guides-schema-organisation.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: schema-organization 3 | title: Schema Organization 4 | --- 5 | 6 | As you add more and more types to your schema, it can grow quite large. 7 | Learn how to split your schema across multiple files and organise your types. 8 | 9 | ## Schema Imports 10 | 11 | Suppose you created your schema files likes this: 12 | 13 | ``` 14 | graphql/ 15 | |-- schema.graphql 16 | |-- user.graphql 17 | ``` 18 | 19 | Lighthouse reads your schema from a single entrypoint, in this case `schema.graphql`. 20 | You can import other schema files from there to split up your schema into multiple files. 21 | 22 | ```graphql 23 | type Query { 24 | user: User 25 | } 26 | 27 | #import user.graphql 28 | ``` 29 | 30 | Imports always begin on a seperate line with `#import `, followed by the relative path 31 | to the imported file. The contents of `user.graphql` are pasted in the final schema. 32 | 33 | ```graphql 34 | type Query { 35 | user: User 36 | } 37 | 38 | type User { 39 | name: String! 40 | } 41 | ``` 42 | 43 | The import statements are followed recursively, so it is easy to organize even the most complex of schemas. 44 | 45 | You can also import multiple files using wildcard import syntax. 46 | For example, if you have your schema files like this: 47 | ``` 48 | graphql/ 49 | |-- schema.graphql 50 | |-- post/ 51 | |-- post.graphql 52 | |-- category.graphql 53 | ``` 54 | 55 | Instead of naming each individual file, you can import multiple files that matches a pattern. 56 | It will be loaded using PHP's [glob function](http://php.net/manual/function.glob.php). 57 | 58 | ```graphql 59 | #import post/*.graphql 60 | ``` 61 | 62 | ## Type Extensions 63 | 64 | Suppose you want to add a new type `Post` to your schema. 65 | Create a new file `post.graphql` with the schema for that type. 66 | 67 | ```graphql 68 | type Post { 69 | title: String 70 | author: User @belongsTo 71 | } 72 | ``` 73 | 74 | Then you add an import to your main schema file. 75 | 76 | ```graphql 77 | #import post.graphql 78 | 79 | type Query { 80 | me: User @auth 81 | } 82 | ``` 83 | 84 | __Attention__: A valid `Query` type definition with at least one field 85 | must be present in the root schema. 86 | This is because `extend type` needs the original type to get merged into. 87 | 88 | Now you want to add a few queries to actually fetch posts. You could add them to the main `Query` type 89 | in your main file, but that spreads the definition apart, and could also grow quite large over time. 90 | Another way would be to extend the `Query` type and colocate the type definition with its Queries in `post.graphql`. 91 | 92 | ```graphql 93 | type Post { 94 | title: String 95 | author: User @belongsTo 96 | } 97 | 98 | extend type Query { 99 | posts: [Post] @paginate 100 | } 101 | ``` 102 | 103 | The fields in the `extend type` definition are merged with those of the original type. 104 | -------------------------------------------------------------------------------- /docs/guides-validation.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: validation 3 | title: Validation 4 | --- 5 | 6 | ## Validating Arguments 7 | 8 | Lighthouse allows you to use [Laravel's validation](https://laravel.com/docs/validation) for your 9 | queries and mutations. The simplest way to leverage the built-in validation rules is to use the 10 | [@rules](directives#rules) directive. 11 | 12 | ```graphql 13 | type Mutation { 14 | createUser( 15 | name: String @rules(apply: ["required", "min:4"]) 16 | email: String @rules(apply: ["email"]) 17 | ): User 18 | } 19 | ``` 20 | 21 | In the case of a validation error, Lighthouse will abort execution and return the validation messages 22 | as part of the response. 23 | 24 | ```graphql 25 | mutation { 26 | createUser(email: "hans@peter.xyz"){ 27 | id 28 | } 29 | } 30 | ``` 31 | 32 | ```json 33 | { 34 | "data":{ 35 | "foo":null 36 | }, 37 | "errors":[ 38 | { 39 | "message":"validation", 40 | "locations":[ 41 | { 42 | "line":2, 43 | "column":13 44 | } 45 | ], 46 | "validation":[ 47 | "The name field is required." 48 | ] 49 | } 50 | ] 51 | } 52 | ``` 53 | 54 | You can customize the error message for a particular argument. 55 | 56 | ```graphql 57 | @create(apply: ["max:140"], message: "Tweets have a limit of 140 characters") 58 | ``` 59 | 60 | ## Custom Validator Classes 61 | 62 | Use the [@validate](directives#validate) directive to validate entire fields 63 | with a custom validator class. 64 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nuwave/lighthouse-docs/a2ca6db8ce910f2575cf0790ebd7a3c5e694748a/logo.png -------------------------------------------------------------------------------- /website/core/Button.js: -------------------------------------------------------------------------------- 1 | const React = require('react') 2 | 3 | const Button = props => ( 4 | 5 | {props.children} 6 | 7 | ) 8 | 9 | module.exports = Button 10 | -------------------------------------------------------------------------------- /website/core/Footer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | const React = require('react') 9 | 10 | const Footer = ({config}) => { 11 | const docUrl = doc => { 12 | return config.baseUrl + 'docs/' + doc 13 | } 14 | 15 | return ( 16 | 57 | ) 58 | } 59 | 60 | module.exports = Footer 61 | -------------------------------------------------------------------------------- /website/i18n/en.json: -------------------------------------------------------------------------------- 1 | { 2 | "_comment": "This file is auto-generated by write-translations.js", 3 | "localized-strings": { 4 | "next": "Next", 5 | "previous": "Previous", 6 | "tagline": "GraphQL Server for Laravel", 7 | "docs": { 8 | "directives": { 9 | "title": "Directives" 10 | }, 11 | "resolvers": { 12 | "title": "Resolvers" 13 | }, 14 | "fields": { 15 | "title": "Fields" 16 | }, 17 | "schema": { 18 | "title": "Schema" 19 | }, 20 | "types": { 21 | "title": "Types" 22 | }, 23 | "configuration": { 24 | "title": "Configuration" 25 | }, 26 | "installation": { 27 | "title": "Installation" 28 | }, 29 | "tutorial": { 30 | "title": "Tutorial" 31 | }, 32 | "auth": { 33 | "title": "Authentication & Authorization" 34 | }, 35 | "plugin-development": { 36 | "title": "Plugin Development" 37 | }, 38 | "relationships": { 39 | "title": "Eloquent Relationships" 40 | }, 41 | "relay": { 42 | "title": "Relay" 43 | }, 44 | "schema-organization": { 45 | "title": "Schema Organization" 46 | }, 47 | "validation": { 48 | "title": "Validation" 49 | }, 50 | "version-2.0-directives-args": { 51 | "title": "Arguments" 52 | }, 53 | "version-2.0-directives-fields": { 54 | "title": "Fields" 55 | }, 56 | "version-2.0-directives-nodes": { 57 | "title": "Nodes" 58 | }, 59 | "version-2.0-configuration": { 60 | "title": "Configuration" 61 | }, 62 | "version-2.0-installation": { 63 | "title": "Installation" 64 | }, 65 | "version-2.0-introduction": { 66 | "title": "Introduction" 67 | }, 68 | "version-2.0-schema-scalars": { 69 | "title": "Scalar types" 70 | }, 71 | "version-2.0-schema": { 72 | "title": "Schema Definition" 73 | }, 74 | "version-2.1-directives-crud": { 75 | "title": "Eloquent CRUD" 76 | }, 77 | "version-2.1-directives-laravel": { 78 | "title": "Laravel Helpers" 79 | }, 80 | "version-2.1-directives-misc": { 81 | "title": "Miscellaneous" 82 | }, 83 | "version-2.1-directives-queries": { 84 | "title": "Eloquent Queries" 85 | }, 86 | "version-2.1-directives-relationships": { 87 | "title": "Eloquent Relationships" 88 | }, 89 | "version-2.1-directives-relay": { 90 | "title": "Relay Helpers" 91 | }, 92 | "version-2.1-directives-schema": { 93 | "title": "Schema Directives" 94 | }, 95 | "version-2.1-directives-security": { 96 | "title": "Security" 97 | }, 98 | "version-2.1-configuration": { 99 | "title": "Configuration" 100 | }, 101 | "version-2.1-installation": { 102 | "title": "Installation" 103 | }, 104 | "version-2.1-schema-extending": { 105 | "title": "Extending the Schema" 106 | }, 107 | "version-2.2-directives": { 108 | "title": "Directives" 109 | }, 110 | "version-2.2-resolvers": { 111 | "title": "Resolvers" 112 | }, 113 | "version-2.2-fields": { 114 | "title": "Fields" 115 | }, 116 | "version-2.2-schema": { 117 | "title": "Schema" 118 | }, 119 | "version-2.2-types": { 120 | "title": "Types" 121 | }, 122 | "version-2.2-configuration": { 123 | "title": "Configuration" 124 | }, 125 | "version-2.2-installation": { 126 | "title": "Installation" 127 | }, 128 | "version-2.2-auth": { 129 | "title": "Authentication & Authorization" 130 | }, 131 | "version-2.2-relationships": { 132 | "title": "Eloquent Relationships" 133 | }, 134 | "version-2.2-relay": { 135 | "title": "Relay" 136 | }, 137 | "version-2.2-schema-organization": { 138 | "title": "Schema organization" 139 | }, 140 | "version-2.2-validation": { 141 | "title": "Validation" 142 | }, 143 | "version-2.3-directives": { 144 | "title": "Directives" 145 | }, 146 | "version-2.3-resolvers": { 147 | "title": "Resolvers" 148 | }, 149 | "version-2.3-fields": { 150 | "title": "Fields" 151 | }, 152 | "version-2.3-types": { 153 | "title": "Types" 154 | }, 155 | "version-2.3-configuration": { 156 | "title": "Configuration" 157 | }, 158 | "version-2.3-installation": { 159 | "title": "Installation" 160 | }, 161 | "version-2.3-plugin-development": { 162 | "title": "Plugin Development" 163 | }, 164 | "version-2.3-relationships": { 165 | "title": "Eloquent Relationships" 166 | }, 167 | "version-2.3-relay": { 168 | "title": "Relay" 169 | }, 170 | "version-2.3-schema-organization": { 171 | "title": "Schema organization" 172 | }, 173 | "version-2.4-directives": { 174 | "title": "Directives" 175 | }, 176 | "version-2.4-fields": { 177 | "title": "Fields" 178 | }, 179 | "version-2.4-configuration": { 180 | "title": "Configuration" 181 | }, 182 | "version-2.5-directives": { 183 | "title": "Directives" 184 | }, 185 | "version-2.5-resolvers": { 186 | "title": "Resolvers" 187 | }, 188 | "version-2.5-types": { 189 | "title": "Types" 190 | }, 191 | "version-2.5-configuration": { 192 | "title": "Configuration" 193 | }, 194 | "version-2.5-auth": { 195 | "title": "Authentication & Authorization" 196 | }, 197 | "version-2.5-plugin-development": { 198 | "title": "Plugin Development" 199 | }, 200 | "version-2.5-relationships": { 201 | "title": "Eloquent Relationships" 202 | }, 203 | "version-2.5-schema-organization": { 204 | "title": "Schema Organization" 205 | }, 206 | "version-2.6-directives": { 207 | "title": "Directives" 208 | }, 209 | "version-2.6-configuration": { 210 | "title": "Configuration" 211 | }, 212 | "version-2.6-installation": { 213 | "title": "Installation" 214 | }, 215 | "version-2.6-tutorial": { 216 | "title": "Tutorial" 217 | } 218 | }, 219 | "links": { 220 | "Docs": "Docs", 221 | "Resources": "Resources", 222 | "Users": "Users", 223 | "GitHub": "GitHub" 224 | }, 225 | "categories": { 226 | "Getting Started": "Getting Started", 227 | "The Basics": "The Basics", 228 | "Guides": "Guides", 229 | "API Reference": "API Reference", 230 | "Schema": "Schema", 231 | "Directives": "Directives" 232 | } 233 | }, 234 | "pages-strings": { 235 | "Help Translate|recruit community translators for your project": "Help Translate", 236 | "Edit this Doc|recruitment message asking to edit the doc source": "Edit", 237 | "Translate this Doc|recruitment message asking to translate the docs": "Translate" 238 | } 239 | } 240 | -------------------------------------------------------------------------------- /website/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "examples": "docusaurus-examples", 4 | "start": "docusaurus-start", 5 | "build": "docusaurus-build", 6 | "publish-gh-pages": "docusaurus-publish", 7 | "write-translations": "docusaurus-write-translations", 8 | "version": "docusaurus-version", 9 | "rename-version": "docusaurus-rename-version", 10 | "tailwind": "./node_modules/.bin/tailwind build ./tailwind/styles.css -c ./tailwind.js -o ./static/css/custom.css", 11 | "tailwind:watch": "nodemon --exec \"tailwind build ./tailwind/styles.css -c ./tailwind.js -o ./static/css/custom.css\" ./tailwind/styles.css" 12 | }, 13 | "devDependencies": { 14 | "docusaurus": "^1.3.2", 15 | "prettier": "^1.13.7", 16 | "tailwindcss": "^0.5.3" 17 | }, 18 | "dependencies": {} 19 | } 20 | -------------------------------------------------------------------------------- /website/pages/en/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | const React = require('react') 9 | 10 | const CompLibrary = require('../../core/CompLibrary.js') 11 | const MarkdownBlock = CompLibrary.MarkdownBlock 12 | 13 | const CWD = process.cwd() 14 | 15 | const Button = require(CWD + '/core/Button.js') 16 | 17 | const Index = () => ( 18 |
19 |
25 |
26 |
27 | 33 |
34 |

35 | Lighthouse 36 |

37 |

GraphQL Server for Laravel

38 |

39 | Lighthouse is a PHP package that allows you to serve a GraphQL 40 | endpoint from your Laravel application. It greatly reduces the 41 | boilerplate required to create a schema, integrates well 42 | with any Laravel project, and is highly customizable giving 43 | you full control over your data. 44 |

45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |

55 | Lighthouse enables schema-first development by allowing you to use the native Schema Definition Language to describe your data. 56 | Leverage server-side directives to add functionality and bring your schema to life. 57 |

58 |

59 | With nothing more than this schema file (along w/ Eloquent 60 | models and migrations set up), you have a fully functional 61 | GraphQL server with no additional code! But don't worry, you 62 | can extend Lighthouse to fit just about any data requirements. 63 | The docs will walk you through what directives are available, 64 | how to create your own directives and how to create your own 65 | resolvers, so let's get started! 66 |

67 | 68 |
69 |
70 |
71 | 72 | {` 73 | \`\`\`graphql 74 | type User { 75 | id: ID! 76 | name: String! 77 | email: String 78 | posts: [Post!] @hasMany 79 | } 80 | 81 | type Post { 82 | title: String! 83 | content: String! 84 | author: User @belongsTo 85 | } 86 | 87 | type Query { 88 | me: User @auth 89 | posts: [Post!] @paginate 90 | } 91 | \`\`\` 92 | `} 93 | 94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |

102 | Rapid GraphQL Development 103 |

104 |

105 | Fully customizable to fit your data requirements. 106 |

107 |
108 |
109 |

110 | Schema Directives 111 |

112 |

113 | Lighthouse provides you with a handful of helpful Schema 114 | Directives to get you up and running in no time. But it also 115 | allows you to create your own when needed. 116 |

117 |
118 |
119 |

120 | Laravel Friendly 121 |

122 |

123 | Lighthouse integrates with your Laravel application without 124 | the need to re-write your entire domain. Just build a GraphQL 125 | schema on top of your current logic and start querying! 126 |

127 |
128 |
129 |

130 | Optimized for Eloquent 131 |

132 |

133 | Eloquent is an extremely powerful ORM. Lighthouse leverages 134 | your current model relationships and creates optimized database queries. 135 |

136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 | 145 | {` 146 | \`\`\`graphql 147 | type Mutation { 148 | createPost( 149 | title: String! @rules(apply: ["min:2"]) 150 | content: String! @rules(apply: ["min:12"]) 151 | ): Post 152 | # Automatically create a new post model 153 | @create(model: "Post") 154 | # Inject the current user's id 155 | @inject(context: "user.id", attr: "user.id") 156 | # Fire an event with the newly created model 157 | @event(fire: "App\\\\Events\\\\PostCreated") 158 | } 159 | \`\`\` 160 | `} 161 | 162 |
163 |
164 |

Laravel & GraphQL

165 |

166 | Lighthouse dramatically reduces the 167 | amount of boilerplate needed to get a GraphQL project up and 168 | running. Many of the familiar concepts from Laravel are converted 169 | into Lighthouse directives, so you can reuse existing logic and 170 | work the way you are used to. 171 |

172 |

173 | If you already have your models and 174 | migrations set up, it only takes minutes to get a GraphQL 175 | server up and running with Lighthouse! 176 |

177 | 178 |
179 |
180 |
181 |
182 |
183 | ) 184 | 185 | module.exports = Index 186 | -------------------------------------------------------------------------------- /website/pages/en/resources.js: -------------------------------------------------------------------------------- 1 | const React = require('react') 2 | 3 | const CompLibrary = require('../../core/CompLibrary.js') 4 | const MarkdownBlock = CompLibrary.MarkdownBlock 5 | const Container = CompLibrary.Container 6 | 7 | const CWD = process.cwd() 8 | 9 | const siteConfig = require(CWD + '/siteConfig.js') 10 | const Button = require(CWD + '/core/Button.js') 11 | const editUrl = siteConfig.editUrl + '../website/resources.js' 12 | 13 | const Resources = () => ( 14 |
15 | 16 | 17 | {` 18 | # Plugins 19 | 20 |
21 | 22 | - [deinternetjongens/lighthouse-utils](https://github.com/deInternetJongens/Lighthouse-Utils) 23 | 24 |
25 | # Tutorials 26 | 27 | - [Video Walkthrough by Christopher Moore](https://youtu.be/y19EaW2X7ac) 28 | - [GraphQL in Laravel done right](https://medium.com/@olivernybroe/graphql-in-laravel-done-right-9cf123d5601b) 29 | - [Testing GraphQL with Laravel](https://medium.com/@olivernybroe/testing-graphql-with-laravel-4d6201b40f68) 30 | 31 |
32 | # Recommended Packages 33 | 34 | - [mll-lab/laravel-graphql-playground](https://github.com/mll-lab/laravel-graphql-playground) 35 | - [mll-lab/graphql-php-scalars](https://github.com/mll-lab/graphql-php-scalars) 36 | `} 37 |
38 |
39 | 40 |
41 |

Have you made a plugin, tutorial or other related package?

42 | 45 |
46 |
47 | ) 48 | 49 | Resources.title = 'Awesome Resources' 50 | 51 | module.exports = Resources 52 | -------------------------------------------------------------------------------- /website/pages/en/users.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | const React = require('react') 9 | 10 | const CompLibrary = require('../../core/CompLibrary.js') 11 | const Container = CompLibrary.Container 12 | 13 | const CWD = process.cwd() 14 | 15 | const siteConfig = require(CWD + '/siteConfig.js') 16 | const Button = require(CWD + '/core/Button.js') 17 | 18 | const Users = () => { 19 | const editUrl = siteConfig.editUrl + '../website/users.js' 20 | const showcase = siteConfig.users.map((user, i) => { 21 | return ( 22 | 23 | {user.caption} 24 | 25 | ) 26 | }) 27 | 28 | return ( 29 |
30 | 31 |
32 |
33 |

Who's Using This?

34 |
35 | 36 |
37 | {showcase} 38 |
39 | 40 |

Are you using this project?

41 | 44 |
45 |
46 |
47 | ) 48 | } 49 | 50 | Users.title = 'Awesome Users' 51 | 52 | module.exports = Users 53 | -------------------------------------------------------------------------------- /website/pages/en/versions.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | const React = require('react') 9 | 10 | const CompLibrary = require('../../core/CompLibrary') 11 | const Container = CompLibrary.Container 12 | 13 | const CWD = process.cwd() 14 | 15 | const siteConfig = require(CWD + '/siteConfig.js') 16 | const versions = require(CWD + '/versions.json') 17 | 18 | const Versions = () => { 19 | const latestVersion = versions[0] 20 | const releasesBaseUrl = `${siteConfig.repoUrl}/releases/tag/v` 21 | return ( 22 |
23 | 24 |
25 |
26 |

{siteConfig.title + ' Versions'}

27 |
28 |

New versions of this project are released every so often.

29 |

Current version (Stable)

30 | 31 | 32 | 33 | 34 | 37 | 40 | 41 | 42 |
{latestVersion} 35 | Documentation 36 | 38 | Release Notes 39 |
43 |

Latest Version

44 | Here you can find the latest documentation and unreleased code. 45 | 46 | 47 | 48 | 49 | 55 | 58 | 59 | 60 |
master 50 | 52 | Documentation 53 | 54 | 56 | Source Code 57 |
61 |

Past Versions

62 | 63 | 64 | {versions.map( 65 | version => 66 | version !== latestVersion && ( 67 | 68 | 69 | 74 | 77 | 78 | ), 79 | )} 80 | 81 |
{version} 70 | 71 | Documentation 72 | 73 | 75 | Release Notes 76 |
82 |

83 | You can find past versions of this project on{' '} 84 | GitHub. 85 |

86 |
87 |
88 |
89 | ) 90 | } 91 | 92 | Versions.title = 'Awesome Versions' 93 | 94 | module.exports = Versions 95 | -------------------------------------------------------------------------------- /website/sidebars.json: -------------------------------------------------------------------------------- 1 | { 2 | "docs": { 3 | "Getting Started": [ 4 | "installation", 5 | "configuration", 6 | "tutorial" 7 | ], 8 | "The Basics": [ 9 | "schema", 10 | "types", 11 | "fields" 12 | ], 13 | "Guides": [ 14 | "schema-organization", 15 | "relay", 16 | "auth", 17 | "validation", 18 | "relationships", 19 | "plugin-development" 20 | ], 21 | "API Reference": [ 22 | "directives", 23 | "resolvers" 24 | ] 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /website/siteConfig.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | // See https://docusaurus.io/docs/site-config.html for all the possible 9 | // site configuration options. 10 | 11 | // Users are listed in a seperate config file 12 | const users = require('./users.js') 13 | 14 | const siteConfig = { 15 | title: 'Lighthouse', 16 | tagline: 'GraphQL Server for Laravel', 17 | 18 | url: 'https://lighthouse-php.netlify.com', 19 | // Since this is the only project at the above url, use the root path 20 | baseUrl: '/', 21 | 22 | repoUrl: 'https://github.com/nuwave/lighthouse', 23 | editUrl: 'https://github.com/nuwave/lighthouse-docs/edit/master/docs/', 24 | 25 | // Used for publishing and more 26 | projectName: 'lighthouse-php', 27 | organizationName: 'nuwave', 28 | // For top-level user or org sites, the organization is still the same. 29 | // e.g., for the https://JoelMarcey.github.io site, it would be set like... 30 | // organizationName: 'JoelMarcey' 31 | 32 | headerLinks: [ 33 | { 34 | label: 'Docs', 35 | doc: 'installation', 36 | }, 37 | { 38 | label: 'Resources', 39 | page: 'resources', 40 | }, 41 | { 42 | label: 'Users', 43 | page: 'users', 44 | }, 45 | { 46 | label: 'GitHub', 47 | href: 'https://github.com/nuwave/lighthouse', 48 | }, 49 | ], 50 | users, 51 | 52 | headerIcon: 'img/logo.svg', 53 | footerIcon: 'img/logo.svg', 54 | favicon: 'img/favicon.png', 55 | 56 | colors: { 57 | primaryColor: '#A74FF4', 58 | secondaryColor: '#191E38', 59 | }, 60 | 61 | fonts: { 62 | myFont: ['Miriam Libre', 'Serif'], 63 | myOtherFont: ['-apple-system', 'system-ui'], 64 | }, 65 | 66 | // This copyright info is used in /core/Footer.js and blog rss/atom feeds. 67 | copyright: 'Copyright © ' + new Date().getFullYear() + ' Christopher Moore', 68 | 69 | // Use prism for syntax highlighting, as highlightjs does not support graphql 70 | usePrism: true, 71 | 72 | // Add custom scripts here that would be placed in