diff --git a/docs/adonisjs.md b/docs/adonisjs.md new file mode 100644 index 000000000..d67b2d0e3 --- /dev/null +++ b/docs/adonisjs.md @@ -0,0 +1,45 @@ +--- +title: AdonisJS Integration +sidebar_label: AdonisJS +--- + +[`@foadonis/graphql`](https://friendsofadonis.com/docs/graphql) is a fully featured package to build GraphQL APIs with [AdonisJS](https://adonisjs.com/) powered by TypeGraphQL and [Apollo Server](https://www.apollographql.com/docs/apollo-server). + +It supports subscriptions out of the box and brings scalars for [Luxon](https://moment.github.io/luxon/#/) and [VineJS](https://vinejs.dev/). It also provide some helpers for authorization to create a seemless experience for building GraphQL APIs. + +## Overview + +To get started on an existing AdonisJS project a single command is required, it will install all the required dependencies: + +```sh +node ace add @foadonis/graphql +``` + +Once done, you can start your AdonisJS application and access [http://localhost:3000/graphql](http://localhost:3000/graphql) that will great you with the [Apollo Sandbox](https://www.apollographql.com/docs/apollo-sandbox). + +You can create your first resolver like so: + +```ts +import Recipe from "#models/recipe"; +import { Query, Resolver } from "@foadonis/graphql"; + +@Resolver() +export default class RecipeResolver { + @Query(() => [Recipe]) + recipes() { + return Recipe.query(); + } +} +``` + +Register your freshly created resolver in `start/graphql.ts`: + +```ts +import graphql from "@foadonis/graphql/services/main"; + +graphql.resolvers([() => import("#graphql/resolvers/recipe_resolver")]); +``` + +## Documentation + +You can find more information on the [Package Documentation Website](https://friendsofadonis.com/docs/graphql). diff --git a/website/i18n/en.json b/website/i18n/en.json index f3103627d..f85b4882c 100644 --- a/website/i18n/en.json +++ b/website/i18n/en.json @@ -5,6 +5,10 @@ "previous": "Previous", "tagline": "Modern framework for GraphQL API in Node.js", "docs": { + "adonisjs": { + "title": "AdonisJS Integration", + "sidebar_label": "AdonisJS" + }, "authorization": { "title": "Authorization" }, @@ -812,6 +816,10 @@ "title": "Argument and Input validation", "sidebar_label": "Validation" }, + "version-2.0.0-rc.2/version-2.0.0-rc.2-adonisjs": { + "title": "AdonisJS Integration", + "sidebar_label": "AdonisJS" + }, "version-2.0.0-rc.2/version-2.0.0-rc.2-authorization": { "title": "Authorization" }, diff --git a/website/sidebars.json b/website/sidebars.json index 3e38e15ac..c4cdfe243 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -29,7 +29,7 @@ "custom-decorators", "complexity" ], - "Integrations": ["prisma", "nestjs"], + "Integrations": ["prisma", "nestjs", "adonisjs"], "Others": ["emit-schema", "performance"], "Recipes": ["browser-usage", "aws-lambda", "azure-functions"] }, diff --git a/website/versioned_docs/version-2.0.0-rc.2/adonisjs.md b/website/versioned_docs/version-2.0.0-rc.2/adonisjs.md new file mode 100644 index 000000000..2bd08445e --- /dev/null +++ b/website/versioned_docs/version-2.0.0-rc.2/adonisjs.md @@ -0,0 +1,47 @@ +--- +title: AdonisJS Integration +sidebar_label: AdonisJS +id: version-2.0.0-rc.2-adonisjs +original_id: adonisjs +--- + +[`@foadonis/graphql`](https://friendsofadonis.com/docs/graphql) is a fully featured package to build GraphQL APIs with [AdonisJS](https://adonisjs.com/) powered by TypeGraphQL and [Apollo Server](https://www.apollographql.com/docs/apollo-server). + +It supports subscriptions out of the box and brings scalars for [Luxon](https://moment.github.io/luxon/#/) and [VineJS](https://vinejs.dev/). It also provide some helpers for authorization to create a seamless experience for building GraphQL APIs. + +## Overview + +To get started on an existing AdonisJS project a single command is required, it will install all the required dependencies and generate configuration files: + +```sh +node ace add @foadonis/graphql +``` + +Once done, you can start your AdonisJS application and access [http://localhost:3000/graphql](http://localhost:3000/graphql) that will great you with the [Apollo Sandbox](https://www.apollographql.com/docs/apollo-sandbox). + +You can create your first resolver like so: + +```ts +import Recipe from "#models/recipe"; +import { Query, Resolver } from "@foadonis/graphql"; + +@Resolver() +export default class RecipeResolver { + @Query(() => [Recipe]) + recipes() { + return Recipe.query(); + } +} +``` + +Register your freshly created resolver in `start/graphql.ts`: + +```ts +import graphql from "@foadonis/graphql/services/main"; + +graphql.resolvers([() => import("#graphql/resolvers/recipe_resolver")]); +``` + +## Documentation + +You can find more information on the [package documentation website](https://friendsofadonis.com/docs/graphql). diff --git a/website/versioned_sidebars/version-2.0.0-rc.2-sidebars.json b/website/versioned_sidebars/version-2.0.0-rc.2-sidebars.json index 72b6126e1..6af35895b 100644 --- a/website/versioned_sidebars/version-2.0.0-rc.2-sidebars.json +++ b/website/versioned_sidebars/version-2.0.0-rc.2-sidebars.json @@ -35,7 +35,8 @@ ], "Integrations": [ "version-2.0.0-rc.2-prisma", - "version-2.0.0-rc.2-nestjs" + "version-2.0.0-rc.2-nestjs", + "version-2.0.0-rc.2-adonisjs" ], "Others": [ "version-2.0.0-rc.2-emit-schema",