From 86340bb27e11d4de58f5cd23e8f4dab6bcee67ca Mon Sep 17 00:00:00 2001 From: Jigs Date: Thu, 19 May 2022 14:47:18 -0600 Subject: [PATCH] Deploy website - based on 7a7e80e4ea7f79728af39c5d3292a00d8c6f0c24 --- 404.html | 4 ++-- assets/js/0e384e19.7922b6fa.js | 1 + assets/js/0e384e19.c904f81f.js | 1 - .../{runtime~main.45fad042.js => runtime~main.c8fbc6db.js} | 2 +- blog.html | 4 ++-- blog/archive.html | 4 ++-- blog/first-blog-post.html | 4 ++-- blog/tags.html | 4 ++-- blog/tags/connections.html | 4 ++-- blog/tags/relay-connections.html | 4 ++-- blog/tags/relay.html | 4 ++-- blog/tags/typegraphql-relay-connections.html | 4 ++-- blog/tags/typegraphql.html | 4 ++-- docs/Examples.html | 4 ++-- docs/api/connection-type.html | 4 ++-- docs/api/edge-type.html | 4 ++-- docs/intro.html | 6 +++--- docs/tutorials/custom-cursors.html | 4 ++-- index.html | 4 ++-- markdown-page.html | 4 ++-- 20 files changed, 37 insertions(+), 37 deletions(-) create mode 100644 assets/js/0e384e19.7922b6fa.js delete mode 100644 assets/js/0e384e19.c904f81f.js rename assets/js/{runtime~main.45fad042.js => runtime~main.c8fbc6db.js} (62%) diff --git a/404.html b/404.html index 18239e2..07c6204 100644 --- a/404.html +++ b/404.html @@ -6,13 +6,13 @@ Page Not Found | TypeGraphQL Relay Connections - +
Skip to main content

Page Not Found

We could not find what you were looking for.

Please contact the owner of the site that linked you to the original URL and let them know their link is broken.

- + \ No newline at end of file diff --git a/assets/js/0e384e19.7922b6fa.js b/assets/js/0e384e19.7922b6fa.js new file mode 100644 index 0000000..9dd7c30 --- /dev/null +++ b/assets/js/0e384e19.7922b6fa.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunktypegraphql_relay_connections_docs=self.webpackChunktypegraphql_relay_connections_docs||[]).push([[671],{3905:function(e,n,t){t.d(n,{Zo:function(){return c},kt:function(){return y}});var r=t(7294);function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function a(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function i(e){for(var n=1;n=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var p=r.createContext({}),l=function(e){var n=r.useContext(p),t=n;return e&&(t="function"==typeof e?e(n):i(i({},n),e)),t},c=function(e){var n=l(e.components);return r.createElement(p.Provider,{value:n},e.children)},u={inlineCode:"code",wrapper:function(e){var n=e.children;return r.createElement(r.Fragment,{},n)}},d=r.forwardRef((function(e,n){var t=e.components,o=e.mdxType,a=e.originalType,p=e.parentName,c=s(e,["components","mdxType","originalType","parentName"]),d=l(t),y=o,h=d["".concat(p,".").concat(y)]||d[y]||u[y]||a;return t?r.createElement(h,i(i({ref:n},c),{},{components:t})):r.createElement(h,i({ref:n},c))}));function y(e,n){var t=arguments,o=n&&n.mdxType;if("string"==typeof e||o){var a=t.length,i=new Array(a);i[0]=d;var s={};for(var p in n)hasOwnProperty.call(n,p)&&(s[p]=n[p]);s.originalType=e,s.mdxType="string"==typeof e?e:o,i[1]=s;for(var l=2;l SongConnection)\n async songs(\n @Args() forwardPaging: ForwardPaginationArgs,\n @Args() backwardPaging: BackwardPaginationArgs\n ): Promise {\n // implementation up to you!\n return controller.getSongs({forwardPaging, backwardPaging});\n }\n}\n\nconst PORT = 4000;\n\nasync function bootstrap() {\n const schema = await buildSchema({\n resolvers: [SongResolver]\n });\n\n // Create the GraphQL server\n const server = new ApolloServer({\n schema\n });\n\n // Start the server\n const { url } = await server.listen(PORT);\n console.log(`Server is running, GraphQL Playground available at ${url}`);\n}\n\nbootstrap();\n")),(0,a.kt)("h2",{id:"using-mongoose"},"Using mongoose?"),(0,a.kt)("p",null,"There is a companion library available called ",(0,a.kt)("a",{parentName:"p",href:"https://www.npmjs.com/package/mongoose-relay-paginate"},"mongoose-relay-paginate"),"! It works great with this library."))}y.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/0e384e19.c904f81f.js b/assets/js/0e384e19.c904f81f.js deleted file mode 100644 index cba9fb0..0000000 --- a/assets/js/0e384e19.c904f81f.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunktypegraphql_relay_connections_docs=self.webpackChunktypegraphql_relay_connections_docs||[]).push([[671],{3905:function(e,n,t){t.d(n,{Zo:function(){return c},kt:function(){return y}});var r=t(7294);function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function a(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function i(e){for(var n=1;n=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var p=r.createContext({}),l=function(e){var n=r.useContext(p),t=n;return e&&(t="function"==typeof e?e(n):i(i({},n),e)),t},c=function(e){var n=l(e.components);return r.createElement(p.Provider,{value:n},e.children)},u={inlineCode:"code",wrapper:function(e){var n=e.children;return r.createElement(r.Fragment,{},n)}},d=r.forwardRef((function(e,n){var t=e.components,o=e.mdxType,a=e.originalType,p=e.parentName,c=s(e,["components","mdxType","originalType","parentName"]),d=l(t),y=o,h=d["".concat(p,".").concat(y)]||d[y]||u[y]||a;return t?r.createElement(h,i(i({ref:n},c),{},{components:t})):r.createElement(h,i({ref:n},c))}));function y(e,n){var t=arguments,o=n&&n.mdxType;if("string"==typeof e||o){var a=t.length,i=new Array(a);i[0]=d;var s={};for(var p in n)hasOwnProperty.call(n,p)&&(s[p]=n[p]);s.originalType=e,s.mdxType="string"==typeof e?e:o,i[1]=s;for(var l=2;l SongConnection)\n async songs(\n @Args() forwardPaging: ForwardPaginationArgs,\n @Args() backwardPaging: BackwardPaginationArgs\n ): Promise {\n // implementation up to you!\n return controller.getSongs({forwardPaging, backwardPaging});\n }\n}\n\nconst PORT = 4000;\n\nasync function bootstrap() {\n const schema = await buildSchema({\n resolvers: [SongResolver]\n });\n\n // Create the GraphQL server\n const server = new ApolloServer({\n schema\n });\n\n // Start the server\n const { url } = await server.listen(PORT);\n console.log(`Server is running, GraphQL Playground available at ${url}`);\n}\n\nbootstrap();\n")))}y.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/runtime~main.45fad042.js b/assets/js/runtime~main.c8fbc6db.js similarity index 62% rename from assets/js/runtime~main.45fad042.js rename to assets/js/runtime~main.c8fbc6db.js index 27a3c3c..a838286 100644 --- a/assets/js/runtime~main.45fad042.js +++ b/assets/js/runtime~main.c8fbc6db.js @@ -1 +1 @@ -!function(){"use strict";var e,t,n,r,o,a={},f={};function c(e){var t=f[e];if(void 0!==t)return t.exports;var n=f[e]={id:e,loaded:!1,exports:{}};return a[e].call(n.exports,n,n.exports,c),n.loaded=!0,n.exports}c.m=a,c.c=f,e=[],c.O=function(t,n,r,o){if(!n){var a=1/0;for(d=0;d=o)&&Object.keys(c.O).every((function(e){return c.O[e](n[i])}))?n.splice(i--,1):(f=!1,o0&&e[d-1][2]>o;d--)e[d]=e[d-1];e[d]=[n,r,o]},c.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return c.d(t,{a:t}),t},n=Object.getPrototypeOf?function(e){return Object.getPrototypeOf(e)}:function(e){return e.__proto__},c.t=function(e,r){if(1&r&&(e=this(e)),8&r)return e;if("object"==typeof e&&e){if(4&r&&e.__esModule)return e;if(16&r&&"function"==typeof e.then)return e}var o=Object.create(null);c.r(o);var a={};t=t||[null,n({}),n([]),n(n)];for(var f=2&r&&e;"object"==typeof f&&!~t.indexOf(f);f=n(f))Object.getOwnPropertyNames(f).forEach((function(t){a[t]=function(){return e[t]}}));return a.default=function(){return e},c.d(o,a),o},c.d=function(e,t){for(var n in t)c.o(t,n)&&!c.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},c.f={},c.e=function(e){return Promise.all(Object.keys(c.f).reduce((function(t,n){return c.f[n](e,t),t}),[]))},c.u=function(e){return"assets/js/"+({13:"01a85c17",53:"935f2afb",71:"abe3ca9f",77:"4de4073a",85:"1f391b9e",89:"a6aa9e1f",99:"5715148b",103:"ccc49370",131:"ad314d3e",133:"c7ed8530",155:"1700d2bd",195:"29697024",237:"1df93b7f",273:"af5cd4f0",368:"9afdc237",387:"b800e848",402:"5a382e87",414:"393be207",415:"a7db6169",465:"8db28ff5",514:"1be78505",535:"814f3328",566:"0be9cf94",608:"9e4087bc",610:"6875c492",627:"11eadd31",671:"0e384e19",873:"02823e88",918:"17896441",924:"c6de5f76",929:"54adf0a5",955:"c34708ba"}[e]||e)+"."+{13:"07f633d8",53:"ab4eef49",71:"3b141901",75:"4449541c",77:"a0e10d4f",85:"2b5ca739",89:"4937be87",99:"136c093a",103:"ce13ace1",131:"008610d5",133:"e37a04df",155:"5860ef77",195:"d22da7c5",237:"ef71a848",273:"3e318c07",368:"82c76519",387:"4f654161",402:"0d46c31c",414:"e3ef2757",415:"32be2ef0",465:"4c6d1887",514:"d92495be",535:"2ab86a39",566:"f7df093b",608:"3af733db",610:"52a723e3",627:"5c4e2341",671:"c904f81f",873:"10cd58b7",897:"5853a3f4",918:"43744916",924:"bcc0eb3a",929:"9126686f",955:"fe4da965"}[e]+".js"},c.miniCssF=function(e){},c.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r={},o="typegraphql-relay-connections-docs:",c.l=function(e,t,n,a){if(r[e])r[e].push(t);else{var f,i;if(void 0!==n)for(var u=document.getElementsByTagName("script"),d=0;d=o)&&Object.keys(c.O).every((function(e){return c.O[e](n[i])}))?n.splice(i--,1):(a=!1,o0&&e[d-1][2]>o;d--)e[d]=e[d-1];e[d]=[n,r,o]},c.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return c.d(t,{a:t}),t},n=Object.getPrototypeOf?function(e){return Object.getPrototypeOf(e)}:function(e){return e.__proto__},c.t=function(e,r){if(1&r&&(e=this(e)),8&r)return e;if("object"==typeof e&&e){if(4&r&&e.__esModule)return e;if(16&r&&"function"==typeof e.then)return e}var o=Object.create(null);c.r(o);var f={};t=t||[null,n({}),n([]),n(n)];for(var a=2&r&&e;"object"==typeof a&&!~t.indexOf(a);a=n(a))Object.getOwnPropertyNames(a).forEach((function(t){f[t]=function(){return e[t]}}));return f.default=function(){return e},c.d(o,f),o},c.d=function(e,t){for(var n in t)c.o(t,n)&&!c.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},c.f={},c.e=function(e){return Promise.all(Object.keys(c.f).reduce((function(t,n){return c.f[n](e,t),t}),[]))},c.u=function(e){return"assets/js/"+({13:"01a85c17",53:"935f2afb",71:"abe3ca9f",77:"4de4073a",85:"1f391b9e",89:"a6aa9e1f",99:"5715148b",103:"ccc49370",131:"ad314d3e",133:"c7ed8530",155:"1700d2bd",195:"29697024",237:"1df93b7f",273:"af5cd4f0",368:"9afdc237",387:"b800e848",402:"5a382e87",414:"393be207",415:"a7db6169",465:"8db28ff5",514:"1be78505",535:"814f3328",566:"0be9cf94",608:"9e4087bc",610:"6875c492",627:"11eadd31",671:"0e384e19",873:"02823e88",918:"17896441",924:"c6de5f76",929:"54adf0a5",955:"c34708ba"}[e]||e)+"."+{13:"07f633d8",53:"ab4eef49",71:"3b141901",75:"4449541c",77:"a0e10d4f",85:"2b5ca739",89:"4937be87",99:"136c093a",103:"ce13ace1",131:"008610d5",133:"e37a04df",155:"5860ef77",195:"d22da7c5",237:"ef71a848",273:"3e318c07",368:"82c76519",387:"4f654161",402:"0d46c31c",414:"e3ef2757",415:"32be2ef0",465:"4c6d1887",514:"d92495be",535:"2ab86a39",566:"f7df093b",608:"3af733db",610:"52a723e3",627:"5c4e2341",671:"7922b6fa",873:"10cd58b7",897:"5853a3f4",918:"43744916",924:"bcc0eb3a",929:"9126686f",955:"fe4da965"}[e]+".js"},c.miniCssF=function(e){},c.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r={},o="typegraphql-relay-connections-docs:",c.l=function(e,t,n,f){if(r[e])r[e].push(t);else{var a,i;if(void 0!==n)for(var u=document.getElementsByTagName("script"),d=0;d Blog | TypeGraphQL Relay Connections - +
- + \ No newline at end of file diff --git a/blog/archive.html b/blog/archive.html index 30c29b1..1499dbb 100644 --- a/blog/archive.html +++ b/blog/archive.html @@ -6,13 +6,13 @@ Archive | TypeGraphQL Relay Connections - +
- + \ No newline at end of file diff --git a/blog/first-blog-post.html b/blog/first-blog-post.html index 1a02d45..10ef677 100644 --- a/blog/first-blog-post.html +++ b/blog/first-blog-post.html @@ -6,13 +6,13 @@ First Blog Post | TypeGraphQL Relay Connections - +
- + \ No newline at end of file diff --git a/blog/tags.html b/blog/tags.html index c308632..4c748ab 100644 --- a/blog/tags.html +++ b/blog/tags.html @@ -6,13 +6,13 @@ Tags | TypeGraphQL Relay Connections - + - + \ No newline at end of file diff --git a/blog/tags/connections.html b/blog/tags/connections.html index a39ec5a..27beb54 100644 --- a/blog/tags/connections.html +++ b/blog/tags/connections.html @@ -6,13 +6,13 @@ One post tagged with "connections" | TypeGraphQL Relay Connections - +

One post tagged with "connections"

View All Tags
- + \ No newline at end of file diff --git a/blog/tags/relay-connections.html b/blog/tags/relay-connections.html index 4b409b1..a199062 100644 --- a/blog/tags/relay-connections.html +++ b/blog/tags/relay-connections.html @@ -6,13 +6,13 @@ One post tagged with "relay-connections" | TypeGraphQL Relay Connections - +

One post tagged with "relay-connections"

View All Tags
- + \ No newline at end of file diff --git a/blog/tags/relay.html b/blog/tags/relay.html index 19dfa76..359d6e9 100644 --- a/blog/tags/relay.html +++ b/blog/tags/relay.html @@ -6,13 +6,13 @@ One post tagged with "relay" | TypeGraphQL Relay Connections - +

One post tagged with "relay"

View All Tags
- + \ No newline at end of file diff --git a/blog/tags/typegraphql-relay-connections.html b/blog/tags/typegraphql-relay-connections.html index a43d528..eabba2f 100644 --- a/blog/tags/typegraphql-relay-connections.html +++ b/blog/tags/typegraphql-relay-connections.html @@ -6,13 +6,13 @@ One post tagged with "typegraphql-relay-connections" | TypeGraphQL Relay Connections - +

One post tagged with "typegraphql-relay-connections"

View All Tags
- + \ No newline at end of file diff --git a/blog/tags/typegraphql.html b/blog/tags/typegraphql.html index 1c3efe4..1dcec74 100644 --- a/blog/tags/typegraphql.html +++ b/blog/tags/typegraphql.html @@ -6,13 +6,13 @@ One post tagged with "typegraphql" | TypeGraphQL Relay Connections - +

One post tagged with "typegraphql"

View All Tags
- + \ No newline at end of file diff --git a/docs/Examples.html b/docs/Examples.html index 0daa757..c9c28a2 100644 --- a/docs/Examples.html +++ b/docs/Examples.html @@ -6,13 +6,13 @@ TypeGraphQL Example 🏋️‍♂️ | TypeGraphQL Relay Connections - +

TypeGraphQL Example 🏋️‍♂️

See the tests and the example folder for more examples.

Here's a full-fledged typegraphql server example (codesandbox link):

import "reflect-metadata";
import { ApolloServer } from "apollo-server";
import {
ObjectType,
Field,
Resolver,
Query,
Mutation,
Arg,
InputType,
buildSchema,
Args
} from "type-graphql";
import {
EdgeType,
ConnectionType,
BackwardPaginationArgs,
ForwardPaginationArgs
} from "typegraphql-relay-connections";
import { edgesToReturn } from "./pagination.example";

// Setup GraphQL Schema
@ObjectType()
class Book {
@Field()
title!: string;
@Field()
author!: string;
}

@InputType()
class NewBookInput {
@Field()
title!: string;
@Field()
author!: string;
}

// setup relay connection types
@ObjectType()
class BookEdge extends EdgeType(Book) {}

@ObjectType()
class BookConnection extends ConnectionType({
edge: BookEdge,
node: Book
}) {}

declare module "typegraphql-relay-connections" {
interface Cursor {
id: string;
}
}

// usually you have some form of database this will do okay for an example
const books: Book[] = [
{
title: "Three Little Pigs",
author: "Joseph Jacobs"
},
{
title: "A Christmas Carol",
author: "Charles Dickens"
}
];

// Setup resolver
@Resolver(Book)
class BookResolver {
@Query((returns) => BookConnection)
async searchBooksByTitle(
@Args() backwardPaging: BackwardPaginationArgs,
@Args() forwardPaging: ForwardPaginationArgs,
@Arg("title") title: string
): Promise<BookConnection> {
const edges = edgesToReturn(
books
.filter((book) => book.title.includes(title))
.map((node) => ({
node,
cursor: {
id: node.title
}
})),
{}
);
return {
edges,
nodes: edges.map((x) => x.node),
pageInfo: {
hasNextPage: false,
hasPreviousPage: false,
endCursor: edges[edges.length - 1].cursor,
startCursor: edges[0].cursor,
count: edges.length
}
};
}

@Query((returns) => BookConnection)
async searchBooksByAuthor(
@Arg("author") title: string
): Promise<BookConnection> {
const edges = edgesToReturn(
books
.filter((book) => book.author.includes(title))
.map((node) => ({
node,
cursor: {
id: node.title
}
})),
{}
);
return {
edges,
nodes: edges.map((x) => x.node),
pageInfo: {
hasNextPage: false,
hasPreviousPage: false,
endCursor: edges[edges.length - 1].cursor,
startCursor: edges[0].cursor,
count: edges.length
}
};
}

@Query((returns) => BookConnection)
async allBooks(): Promise<BookConnection> {
const edges = edgesToReturn(
books.map((node) => ({
node,
cursor: {
id: node.title
}
})),
{}
);
return {
edges,
nodes: edges.map((x) => x.node),
pageInfo: {
hasNextPage: false,
hasPreviousPage: false,
endCursor: edges[edges.length - 1].cursor,
startCursor: edges[0].cursor,
count: edges.length
}
};
}

@Mutation((returns) => Book)
async addBook(@Arg("newBookData") newBookData: NewBookInput) {
books.push(newBookData);
return newBookData;
}
}

const PORT = 4000;

async function bootstrap() {
const schema = await buildSchema({
resolvers: [BookResolver]
});

// Create the GraphQL server
const server = new ApolloServer({
schema
});

// Start the server
const { url } = await server.listen(PORT);
console.log(`Server is running, GraphQL Playground available at ${url}`);
}

bootstrap();
- + \ No newline at end of file diff --git a/docs/api/connection-type.html b/docs/api/connection-type.html index 34da93f..a9c10d1 100644 --- a/docs/api/connection-type.html +++ b/docs/api/connection-type.html @@ -6,13 +6,13 @@ ConnectionType 🦔 | TypeGraphQL Relay Connections - +

ConnectionType 🦔

The ConnectionType function is the slightly more complicated of the two main functions. We'll define a full example below, but if we isolate the ConnectionType by itself you'll see it looks like this:

@ObjectType()
export class SongConnection extends ConnectionType({
node: Song,
edge: SongEdge
}) {
// You can add additional Types to your ConnectionType that are specific to it here:
}

To have a more complete example all you need to do is create a ObjectType class, EdgeType class, and then plug them in to the ConnectionType class:

import {ObjectType, Field} from "type-graphql";
import {EdgeType, ConnectionType} from "typegraphql-relay-connections";

// This is our ObjectType:
@ObjectType()
class Song {
@Field()
id!: string

@Field()
title!: string;
}

// This is the EdgeType:
@ObjectType()
export class SongEdge extends EdgeType(Song) {}

// This is the ConnectionType:
@ObjectType()
export class SongConnection extends ConnectionType({
node: Song,
edge: SongEdge
}) {}
- + \ No newline at end of file diff --git a/docs/api/edge-type.html b/docs/api/edge-type.html index 64cbda2..29b45db 100644 --- a/docs/api/edge-type.html +++ b/docs/api/edge-type.html @@ -6,13 +6,13 @@ EdgeType 🧀 | TypeGraphQL Relay Connections - +

EdgeType 🧀

The EdgeType allows you to create a GraphQL relay edge ObjectType from a base type. ObjectTypes are what you can return from any graphql resolver, see the examples for more full implementations of how to connect to resolvers. We'll get to a more full and complete example of EdgeTypes below, but for now here is an isolated example showing how exactly the EdgeType is used.

@ObjectType()
export class SongEdge extends EdgeType(Song) {
// You can add additional properties and values that are specific to your specific EdgeType here...
}

For a more full example, all you need to do is create a base ObjectType Class to pass into the EdgeType function:

import {ObjectType, Field} from "type-graphql";
import {EdgeType} from "typegraphql-relay-connections";

// This is our ObjectType:
@ObjectType()
class Song {
@Field()
id!: string

@Field()
title!: string;
}

// This is the EdgeType:
@ObjectType()
export class SongEdge extends EdgeType(Song) {}
- + \ No newline at end of file diff --git a/docs/intro.html b/docs/intro.html index 3ccd25e..18370d1 100644 --- a/docs/intro.html +++ b/docs/intro.html @@ -6,13 +6,13 @@ Intro 🚀 | TypeGraphQL Relay Connections - +
-

Intro 🚀

This library provides a way to setup typings for TypeGraphQL with Relay Connection Types. Relay Connection Types are a great way to define pagination in an app. This libraries connection types follow the Relay Connection Type Server Standard. You may want to read up on relay if you're confused on what the benefits of relay connections to find out how exactly this library works. Particularly this library implements the second part of the standard, so it accomplishes: 2.) A description of how to page through connections, so you may want to check out the relevant section on connections in the relay GraphQL server standard.

Note that though pagination types and utils are in this repo, the implementation of the paging algorithms are up to the user this is on purpose and is meant to keep this library small and maintanable.

Show Me Da Codez!! 💻

The quickest possible example to show what this library does is the following. We create two GraphQL ObjectTypes using TypeGraphQL object types.

import {
Field,
ObjectType,
} from "type-graphql";
import {
ConnectionType,
EdgeType
} from "typegraphql-relay-connections";

@ObjectType()
class Song {
@Field()
id!: string

@Field()
title!: string;
}

@ObjectType()
export class SongEdge extends EdgeType(Song) {}

@ObjectType()
export class SongConnection extends ConnectionType({
edge: SongEdge,
node: Song,
}) {}

The last thing we can do with this library is extend the built in Cursor like so:

declare module "typegraphql-relay-connections" {
interface Cursor {
id: string;
}
}

Peer Dependencies 🔗

All our peer dependencies are due to TypeGraphQL. Follow the setup section for TypeGraphQL.

yarn add graphql@15 reflect-metadata type-graphql

Background on TypeGraphQL 😎

The idea behind TypeGraphQL is you define your GraphQL types using TypeScript. TypeGraphQL follows a code first approach rather than the schema first approach. Since TypeGraphQL's code first approach is written in TypeScript this allows you to strongly type your GraphQL server.

Introductory Example 🤓

See this intro example on codesandbox

We'll start with some imports for this (you can replace apollo-server with the graphql server you choose to use.):

import "reflect-metadata";
import { ApolloServer } from "apollo-server";
import {
Field,
ObjectType,
Args,
Query,
Resolver,
buildSchema
} from "type-graphql";
import {
ForwardPaginationArgs,
ConnectionType,
EdgeType,
BackwardPaginationArgs
} from "typegraphql-relay-connections";
// you'll have to make this yourself for an example see the codesandbox
import * as controller from "./song.controller";

First create an object-type through type-graphql

@ObjectType()
class Song {
@Field()
id!: string

@Field()
title!: string;
}

That last part was just TypeGraphQL, but next is where this library comes in. It helps you create the Edge and Connection ObjectTypes as well as a custom cursor. Both the EdgeType and ConnectionType functions come from this library.

@ObjectType()
export class SongEdge extends EdgeType(Song) {}

@ObjectType()
export class SongConnection extends ConnectionType({
edge: SongEdge,
node: Song,
}) {}


declare module "typegraphql-relay-connections" {
interface Cursor {
id: string;
}
}

The Rest is just more TypeGraphQL.

@Resolver(Song)
export class SongResolver {
@Query(() => SongConnection)
async songs(
@Args() forwardPaging: ForwardPaginationArgs<Cursor>,
@Args() backwardPaging: BackwardPaginationArgs<Cursor>
): Promise<SongConnection> {
// implementation up to you!
return controller.getSongs({forwardPaging, backwardPaging});
}
}

const PORT = 4000;

async function bootstrap() {
const schema = await buildSchema({
resolvers: [SongResolver]
});

// Create the GraphQL server
const server = new ApolloServer({
schema
});

// Start the server
const { url } = await server.listen(PORT);
console.log(`Server is running, GraphQL Playground available at ${url}`);
}

bootstrap();
- +

Intro 🚀

This library provides a way to setup typings for TypeGraphQL with Relay Connection Types. Relay Connection Types are a great way to define pagination in an app. This libraries connection types follow the Relay Connection Type Server Standard. You may want to read up on relay if you're confused on what the benefits of relay connections to find out how exactly this library works. Particularly this library implements the second part of the standard, so it accomplishes: 2.) A description of how to page through connections, so you may want to check out the relevant section on connections in the relay GraphQL server standard.

Note that though pagination types and utils are in this repo, the implementation of the paging algorithms are up to the user this is on purpose and is meant to keep this library small and maintanable.

Show Me Da Codez!! 💻

The quickest possible example to show what this library does is the following. We create two GraphQL ObjectTypes using TypeGraphQL object types.

import {
Field,
ObjectType,
} from "type-graphql";
import {
ConnectionType,
EdgeType
} from "typegraphql-relay-connections";

@ObjectType()
class Song {
@Field()
id!: string

@Field()
title!: string;
}

@ObjectType()
export class SongEdge extends EdgeType(Song) {}

@ObjectType()
export class SongConnection extends ConnectionType({
edge: SongEdge,
node: Song,
}) {}

The last thing we can do with this library is extend the built in Cursor like so:

declare module "typegraphql-relay-connections" {
interface Cursor {
id: string;
}
}

Peer Dependencies 🔗

All our peer dependencies are due to TypeGraphQL. Follow the setup section for TypeGraphQL.

yarn add graphql@15 reflect-metadata type-graphql

Background on TypeGraphQL 😎

The idea behind TypeGraphQL is you define your GraphQL types using TypeScript. TypeGraphQL follows a code first approach rather than the schema first approach. Since TypeGraphQL's code first approach is written in TypeScript this allows you to strongly type your GraphQL server.

Introductory Example 🤓

See this intro example on codesandbox

We'll start with some imports for this (you can replace apollo-server with the graphql server you choose to use.):

import "reflect-metadata";
import { ApolloServer } from "apollo-server";
import {
Field,
ObjectType,
Args,
Query,
Resolver,
buildSchema
} from "type-graphql";
import {
ForwardPaginationArgs,
ConnectionType,
EdgeType,
BackwardPaginationArgs
} from "typegraphql-relay-connections";
// you'll have to make this yourself for an example see the codesandbox
import * as controller from "./song.controller";

First create an object-type through type-graphql

@ObjectType()
class Song {
@Field()
id!: string

@Field()
title!: string;
}

That last part was just TypeGraphQL, but next is where this library comes in. It helps you create the Edge and Connection ObjectTypes as well as a custom cursor. Both the EdgeType and ConnectionType functions come from this library.

@ObjectType()
export class SongEdge extends EdgeType(Song) {}

@ObjectType()
export class SongConnection extends ConnectionType({
edge: SongEdge,
node: Song,
}) {}


declare module "typegraphql-relay-connections" {
interface Cursor {
id: string;
}
}

The Rest is just more TypeGraphQL.

@Resolver(Song)
export class SongResolver {
@Query(() => SongConnection)
async songs(
@Args() forwardPaging: ForwardPaginationArgs<Cursor>,
@Args() backwardPaging: BackwardPaginationArgs<Cursor>
): Promise<SongConnection> {
// implementation up to you!
return controller.getSongs({forwardPaging, backwardPaging});
}
}

const PORT = 4000;

async function bootstrap() {
const schema = await buildSchema({
resolvers: [SongResolver]
});

// Create the GraphQL server
const server = new ApolloServer({
schema
});

// Start the server
const { url } = await server.listen(PORT);
console.log(`Server is running, GraphQL Playground available at ${url}`);
}

bootstrap();

Using mongoose?

There is a companion library available called mongoose-relay-paginate! It works great with this library.

+ \ No newline at end of file diff --git a/docs/tutorials/custom-cursors.html b/docs/tutorials/custom-cursors.html index 804c969..d11ab58 100644 --- a/docs/tutorials/custom-cursors.html +++ b/docs/tutorials/custom-cursors.html @@ -6,13 +6,13 @@ Extending the Builtin Cursor 📄 | TypeGraphQL Relay Connections - +

Extending the Builtin Cursor 📄

The default Cursor type allows any object value, but you may instead want to extend it with more properties and values which will allow autocomplete of those propety value pairs. You could do that like so:

declare module "typegraphql-relay-connections" {
interface Cursor {
// Your additional property value pairs.
id: string;
}
}
- + \ No newline at end of file diff --git a/index.html b/index.html index 684bcbb..36b0bc5 100644 --- a/index.html +++ b/index.html @@ -6,13 +6,13 @@ Hello from TypeGraphQL Relay Connections | TypeGraphQL Relay Connections - +

TypeGraphQL Relay Connections

Make relay connections easily from TypeGraphQL

typegraphql-relay-connections logo

Easy to Use

TypeGraphQL Relay Connections allows you to easily setup relay connection types for your TypeGraphQL server.

Focus on What Matters

Just import the types and extend a few classes, and you're ready to go.

Bring your own paging algorithm

This library includes types only, so you'll need to make your own paging algorithm.

- + \ No newline at end of file diff --git a/markdown-page.html b/markdown-page.html index ef799db..3c3032b 100644 --- a/markdown-page.html +++ b/markdown-page.html @@ -6,13 +6,13 @@ Markdown page example | TypeGraphQL Relay Connections - +

Markdown page example

You don't need React to write simple standalone pages.

- + \ No newline at end of file