Skip to content

Commit

Permalink
Task: Finish up docs for v0.3.0 (#57)
Browse files Browse the repository at this point in the history
* fix up docs finalize for v0.3.0
  • Loading branch information
roneli authored Jul 16, 2024
1 parent 016af2c commit f298d94
Show file tree
Hide file tree
Showing 23 changed files with 6,692 additions and 2,603 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
init:
strategy:
matrix:
go: [ "1.18", "1.20" ]
go: [ "1.20", "1.22" ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
![fastgql](docs/src/assets/logo_light.svg)
<picture>
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/roneli/fastgql/master/docs/src/assets/logo_light.svg">
<img alt="" src="https://raw.githubusercontent.com/roneli/fastgql/master/docs/src/assets/logo_dark.svg">
</picture>


<div style="align-content: center ">
Expand Down
4 changes: 2 additions & 2 deletions docs/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ export default defineConfig({
},
maxDuration: 8
}),
site: 'https://fastgql.com',
site: 'https://fastgql.io',
base: "/",
integrations: [starlight({
title: 'FastGQL',
favicon: './favicon.svg',
favicon: '/images/favicon.svg',
social: {
github: 'https://github.com/roneli/fastgql'
},
Expand Down
29 changes: 29 additions & 0 deletions docs/src/assets/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions docs/src/content/docs/index.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: fastGQL
description: Get started building your docs site with Starlight.
description: Schema-First GraphQL API Library powered by gqlgen.
template: splash
hero:
title: <div class="logo"/>
Expand All @@ -22,7 +22,8 @@ hero:

import "/src/styles/overrides.css";
import { Card, CardGrid } from '@astrojs/starlight/components';
import ScriptWorkaround from "/src/components/ScriptComponent.astro";
import ScriptWorkaround from "/src/components/ScriptComponent.astro"


<CardGrid stagger>
<Card title="Auto Generate" icon="rocket" class="">
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/mutations/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: GraphQL mutations

GraphQL mutations are used to modify data on the server such as updating, creating or deleting.&#x20;

FastGQL auto generates mutations using the [#generatemutations](../schema/directives.md#generatemutations "mention") directive in your schema.
FastGQL auto generates mutations using the [#generatemutations](../schema/directives#generatemutations "mention") directive in your schema.

## Types of mutations

Expand Down
4 changes: 2 additions & 2 deletions docs/src/content/docs/mutations/delete.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: Delete mutations

import { Tabs, TabItem } from '@astrojs/starlight/components';

FastGQL auto generates `delete<OBJECT_NAME>` delete mutations if the [#generatemutations](../schema/directives.md#generatemutations "mention") is set.
FastGQL auto generates `delete<OBJECT_NAME>` delete mutations if the [#generatemutations](../schema/directives#generatemutations "mention") is set.
The following code will be added to the GraphQL schema.

```graphql
Expand Down Expand Up @@ -50,7 +50,7 @@ type PostsPayload {
}
```

The [#generatemutations](../schema/directives.md#generatemutations "mention") directive adds the above into our schema.
The [#generatemutations](../schema/directives#generatemutations "mention") directive adds the above into our schema.

* **filter** argument passed to `deletePosts`mutation allows to filter what posts we want to delete.
* The **cascade** argument defines if we want to cascade our objects on deletion (postgres only)
Expand Down
4 changes: 2 additions & 2 deletions docs/src/content/docs/mutations/insert.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: Insert mutations

import { Tabs, TabItem } from '@astrojs/starlight/components';

FastGQL auto generates `create<OBJECT_NAME>` insert mutations if the [#generatemutations](../schema/directives.md#generatemutations "mention")is set. The following code will be added to the GraphQL schema.
FastGQL auto generates `create<OBJECT_NAME>` insert mutations if the [#generateMutations](../schema/directives#generatemutations "mention") is set. The following code will be added to the GraphQL schema.

```graphql
// Some code
Expand Down Expand Up @@ -36,7 +36,7 @@ type PostsPayload {
}
```

The [#generatemutations](../schema/directives.md#generatemutations "mention") directive adds the above into our schema.
The [#generateMutations](../schema/directives#generatemutations "mention") directive adds the above into our schema.

* `inputs` argument passed to `createPosts` mutation is required and you can pass 1 or more objects.
* `PostsPayload` is the response object returned from the mutation, returning the amounts of rows\_affected i.e. the amount of objects inserted and access to all our posts info
Expand Down
4 changes: 2 additions & 2 deletions docs/src/content/docs/mutations/update.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: Update mutations

import { Tabs, TabItem } from '@astrojs/starlight/components';

FastGQL auto generates `update<OBJECT_NAME>` update mutations if the [#generatemutations](../schema/directives.md#generatemutations "mention")is set. The following code will be added to the GraphQL schema.
FastGQL auto generates `update<OBJECT_NAME>` update mutations if the [#generatemutations](../schema/directives#generatemutations "mention")is set. The following code will be added to the GraphQL schema.

```graphql

Expand Down Expand Up @@ -57,7 +57,7 @@ type PostsPayload {
}
```

The [#generatemutations](../schema/directives.md#generatemutations "mention") directive adds the above into our schema.
The [#generatemutations](../schema/directives#generatemutations "mention") directive adds the above into our schema.

* `inputs` argument passed to `createPosts` mutation is required and you can pass 1 or more objects.
* `PostsPayload` is the response object returned from the mutation, returning the amounts of rows\_affected i.e. the amount of objects inserted and access to all our posts info
Expand Down
4 changes: 2 additions & 2 deletions docs/src/content/docs/queries/queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: Executing queries on a generated FastGQL Server

FastGQL allows to easily execute queries against a remote data source, i.e. postgres and convert the GraphQL AST into a valid SQL query and return queried data.

FastGQL auto-generates query filters, aggregation, pagination and ordering from your schema definition using the [#generate](../schema/directives.md#generate "mention") and [#generatefilterinput](../schema/directives.md#generatefilterinput "mention") directives.
FastGQL auto-generates query filters, aggregation, pagination and ordering from your schema definition using the [#generate](../schema/directives#generate "mention") and [#generatefilterinput](../schema/directives#generatefilterinput "mention") directives.

## Queries

Expand Down Expand Up @@ -57,4 +57,4 @@ query {
}
```

fetch all users and thier posts, for each post we fetch it's categories and the user who posted it.
fetch all users and their posts, for each post we fetch it's categories and the user who posted it.
14 changes: 8 additions & 6 deletions docs/src/content/docs/reference/example.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
---
title: Example Reference
description: A reference page in my new Starlight docs site.
description: List of examples of FastGQL
---

Reference pages are ideal for outlining how things work in terse and clear terms.
Less concerned with telling a story or addressing a specific use case, they should give a comprehensive outline of what you're documenting.
## Further examples

## Further reading

- Read [about reference](https://diataxis.fr/reference/) in the Diátaxis framework
- [simple](https://github.com/roneli/fastgql/tree/master/example/simple) base example of FastGQL.
- [mutations](https://github.com/roneli/fastgql/tree/master/example/mutations) example of FastGQL with mutations.
- [custom_operator](https://github.com/roneli/fastgql/tree/master/example/custom_operator) example of FastGQL with custom operators.
- [interface](https://github.com/roneli/fastgql/tree/master/example/interface) example of FastGQL with interfaces.
- [tutorial](https://github.com/roneli/fastgql/tree/master/example/init) example of FastGQL using a tutorial.
-
14 changes: 6 additions & 8 deletions docs/src/content/docs/schema/directives.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The `@generateFilterInput` tells the augmenter on which `OBJECT | INTERFACE` to

```graphql
# Generate filter input on an object
directive @generateFilterInput(name: String!, description: String)
directive @generateFilterInput(description: String)
on OBJECT | INTERFACE
```

Expand All @@ -32,27 +32,25 @@ directive @generateFilterInput(name: String!, description: String)
In this example, we can are creating a filter input for the category type, when arguments will be generated for categories in `Query` the CategoryFilterInput will be used for the `filter` argument.

```graphql
type Category @generateFilterInput(name: "CategoryFilterInput"){
type Category @generateFilterInput {
id: Int!
name: String
}

type Query @generate {
categories: [Category]
type Query {
categories: [Category] @generate
}
```

This also works for objects that contain fields of objects, see [Object filters](../../../queries/filter/#object-filters)

### @generate

The `@generate` tells the augmenter on which `OBJECT` to generate arguments i.e. filter, pagination and ordering, aggregation. By default, all arguments are created, and are recursive, this means that arguments are generated from the top level `OBJECT` until exhausted meaning no new OBJECT fields are found in a certain level.
The `@generate` tells the augmenter on which `FIELD_DEFINTION` to generate arguments i.e. filter, pagination and ordering, aggregation. By default, all arguments are created, and are recursive, this means that arguments are generated from the top level `OBJECT` until exhausted meaning no new OBJECT fields are found in a certain level.

```graphql
# Generate arguments for a given field or all object fields
directive @generate(filter: Boolean = True,
pagination: Boolean = True, ordering: Boolean = True,
aggregate: Boolean = True, recursive: Boolean = True, filterTypeName: String) on FIELD_DEFINITION
directive @generate(filter: Boolean = True, pagination: Boolean = True, ordering: Boolean = True, aggregate: Boolean = True, recursive: Boolean = True, filterTypeName: String) on FIELD_DEFINITION
```

**Example**: The following example generates resolvers for posts and users, but doesn't add aggregation to users.
Expand Down
8 changes: 7 additions & 1 deletion docs/src/content/docs/schema/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ this available.

# ================== schema generation fastgql directives ==================

# ================== schema generation fastgql directives ==================

# Generate Resolver directive tells fastgql to generate an automatic resolver for a given field
# @generateResolver can only be defined on Query and Mutation fields.
# adding pagination, ordering, aggregate, filter to false will disable the generation of the corresponding arguments
# for filter to work @generateFilterInput must be defined on the object, if its missing you will get an error
# recursive will generate pagination, filtering, ordering and aggregate for all the relations of the object,
# this will modify the object itself and add arguments to the object fields.
directive @generate(filter: Boolean = True, pagination: Boolean = True, ordering: Boolean = True, aggregate: Boolean = True, recursive: Boolean = True, F: String) on FIELD_DEFINITION
directive @generate(filter: Boolean = True, pagination: Boolean = True, ordering: Boolean = True, aggregate: Boolean = True, recursive: Boolean = True, filterTypeName: String) on FIELD_DEFINITION

# Generate mutations for an object
directive @generateMutations(create: Boolean = True, delete: Boolean = True, update: Boolean = True) on OBJECT
Expand Down Expand Up @@ -66,6 +68,10 @@ enum _OrderingTypes {
DESC_NULL_LAST
}

type _AggregateResult {
count: Int!
}

input StringComparator {
eq: String
neq: String
Expand Down
36 changes: 18 additions & 18 deletions docs/src/content/docs/start/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: How to setup fastGQL
This tutorial will take you through the process of building a GraphQL server with fastgql that can:
automatically query, filter, order and pagination users, posts & categories from a postgres database.

You can find the finished code for this tutorial [here](https://github.com/roneli/fastgql/tree/master/example/tutorial).
You can find the finished code for this tutorial [here](https://github.com/roneli/fastgql/tree/master/example/init).

If you are familiar with [gqlgen](https://gqlgen.com), the setup is nearly identical, with a little work in your Schema you won't need to define any resolvers!

Expand Down Expand Up @@ -63,30 +63,30 @@ The schema that was generated for us was:

{% code overflow="wrap" %}
```graphql
type User @generateFilterInput(name: "UserFilterInput") @tableName(name: "user"){
id: Int!
name: String!
posts: [Post] @relation(relationType: ONE_TO_MANY, baseTable: "user", refTable: "posts", fields: ["id"], references: ["user_id"])
type User @generateFilterInput @table(name: "user"){
id: Int!
name: String!
posts: [Post] @relation(type: ONE_TO_MANY, fields: ["id"], references: ["user_id"])
}

type Post @generateFilterInput(name: "PostFilterInput") {
id: Int!
name: String
categories: [Category] @relation(relationType: MANY_TO_MANY, baseTable: "posts", refTable: "categories", fields: ["id"], references: ["id"]
manyToManyTable: "posts_to_categories", manyToManyFields: ["post_id"], manyToManyReferences: ["category_id"])
user: User @relation(relationType: ONE_TO_ONE, baseTable: "posts", refTable: "user", fields: ["user_id"], references: ["id"])
type Post @generateFilterInput @table(name: "posts") {
id: Int!
name: String
categories: [Category] @relation(type: MANY_TO_MANY, fields: ["id"], references: ["id"]
manyToManyTable: "posts_to_categories", manyToManyFields: ["post_id"], manyToManyReferences: ["category_id"])
user: User @relation(type: ONE_TO_ONE, fields: ["user_id"], references: ["id"])
}


type Category @generateFilterInput(name: "CategoryFilterInput"){
id: Int!
name: String
type Category @generateFilterInput @table(name: "categories") {
id: Int!
name: String
}

type Query @generate {
posts: [Post]
users: [User]
categories: [Category] @skipGenerate
type Query {
posts: [Post] @generate
users: [User] @generate
categories: [Category] @generate
}
```
{% endcode %}
Expand Down
9 changes: 6 additions & 3 deletions examples/simple/graph/fastgql.graphql
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
directive @fastgqlField(skipSelect: Boolean = True) on FIELD_DEFINITION
directive @generate(filter: Boolean = True, pagination: Boolean = True, ordering: Boolean = True, aggregate: Boolean = True, recursive: Boolean = True) on FIELD_DEFINITION
directive @generateFilterInput(description: String) on OBJECT
directive @generate(filter: Boolean = True, pagination: Boolean = True, ordering: Boolean = True, aggregate: Boolean = True, recursive: Boolean = True, filterTypeName: String) on FIELD_DEFINITION
directive @generateFilterInput(description: String) on OBJECT | INTERFACE
directive @generateMutations(create: Boolean = True, delete: Boolean = True, update: Boolean = True) on OBJECT
directive @isInterfaceFilter on INPUT_FIELD_DEFINITION
directive @relation(type: _relationType!, fields: [String!]!, references: [String!]!, manyToManyTable: String = "", manyToManyFields: [String] = [], manyToManyReferences: [String] = []) on FIELD_DEFINITION
directive @table(name: String!, dialect: String! = "postgres", schema: String = "") on OBJECT | INTERFACE
directive @typename(name: String!) on INTERFACE
scalar Map

input BooleanComparator {
eq: Boolean
neq: Boolean
Expand Down Expand Up @@ -51,7 +55,6 @@ input IntListComparator {
overlap: [Int]
isNull: Boolean
}
scalar Map
input StringComparator {
eq: String
neq: String
Expand Down
Loading

0 comments on commit f298d94

Please sign in to comment.