A postgraphile plugin that allows you to expose only a single direction of connections exposed by foreign key constraints

Overview

postgraphile-plugin-foreign-field-direction

This plugin allows you to expose only a single direction of connections exposed by foreign key constraints.

Example

With the following schema

create table classroom (
    id int primary key,
    name text
);
create table teacher (
    id int primary key,
    classroom_id int not null references classroom(id)
);

in the GraphQL generated, the Teacher type will have a classroomByClassroomId field, and the Classroom type will have a teachersByClassroomId field.

By using the foreignFieldDirection smart tag, you can choose to expose only one of those two fields.

For example, via a smart comment

teacher_classroom_id_fkey on teacher is E'@foreignFieldDirection forward';

Usage

This is a simple plugin. You can just copy it into your project and modify as needed. You can install it using npm or yarn:

yarn add postgraphile-plugin-foreign-field-direction
const { ForeignFieldDirectionPlugin } = require('postgraphile-plugin-foreign-field-direction')

Smart Tag Arguments

forward and backward are the only valid arguments for the foreignFieldDirection smart tag. Any other value, including a blank value, will set throw an error and prevent the GQL schema from compiling.

The forward argument indicates that you want to expose a traversal only FROM the table on which the constraint is defined.

The backward argument indicates that you want to expose a traversal only TO the table on which the constraint is defined.

Compatibility

This plugin has no dependencies. It was tested with Postgraphile v4.12.9.

You might also like...

Zotero plugin for syncing items into a Notion database

Zotero plugin for syncing items into a Notion database

Notero A Zotero plugin that syncs items into a Notion database when added to a specific collection. Scaffolded with generator-zotero-plugin and built

Jan 9, 2023

graphql-codegen plugin to generate type-safe, easy-to use hooks for Flutter

graphql-codegen-flutter-artemis-hooks This is graphql-codegen plugin to generate type-safe, easy-to use Flutter artemis hooks. For further detail, see

Jan 2, 2023

Fastify is a web framework highly focused on providing the best developer experience with the least overhead and a powerful plugin architecture, inspired by Hapi and Express.

Fastify is a web framework highly focused on providing the best developer experience with the least overhead and a powerful plugin architecture, inspired by Hapi and Express.

Oct 11, 2022

Azure Data Studio is a data management tool that enables you to work with SQL Server, Azure SQL DB and SQL DW from Windows, macOS and Linux.

Azure Data Studio is a data management tool that enables you to work with SQL Server, Azure SQL DB and SQL DW from Windows, macOS and Linux.

Azure Data Studio is a data management tool that enables working with SQL Server, Azure SQL DB and SQL DW from Windows, macOS and Linux.

Dec 31, 2022

In how many ways can you print in the console 50 times?

In how many ways can you print in the console 50 times I was asked at an interview how to print in the console "Hello World" 50 times in as few lines

Oct 4, 2021

Welcome to the LEGO Games Repository, where you can enjoy anytime, anywhere. This is the 2021 KNU Advanced Web Programming team project.

Welcome to the LEGO Games Repository, where you can enjoy anytime, anywhere. This is the 2021 KNU Advanced Web Programming team project.

Welcome to LEGO git repository! Here are some useful information about LEGO service. 0. Docker image Link : https://hub.docker.com/r/leibniz21c/legoga

Jul 21, 2022

A Gmail Clone which built with ReactJS and Redux. You can sign in with your Google Account, compose a new e-mail and send realtime emails to the project.

Gmail Clone with ReactJS A Gmail Clone that you can sign in with your Google Account, compose a new e-mail and send realtime emails to the project. Cl

Nov 14, 2022

The Cassandra/Scylla library you didn't want but got anyways.

The Cassandra/Scylla library you didn't want but got anyways.

Installation Using npm: npm install scyllo or if you prefer to use the yarn package manager: yarn add scyllo Usage import { ScylloClient } from 'scyll

Jul 20, 2022

Tools that eat glass so you don't have to

GlassEater Tools that eat glass so you don't have to. Docs coming soon... Features generates the most precise and optimal getProgramAccounts queries p

Sep 27, 2022
Releases(v2.0.0)
Owner
Chandler Gonzales
Chandler Gonzales
Simple key-value storage with support for multiple backends

Simple key-value storage with support for multiple backends Keyv provides a consistent interface for key-value storage across multiple backends via st

Luke Childs 2k Jan 7, 2023
Fast and advanced, document based and key-value based NoSQL database that able to work as it is installed.

About Fast and advanced, document based and key-value based NoSQL database that able to work as it is installed. Features NoSQL database Can be run as

null 6 Dec 7, 2022
Fast and advanced, document-based and key-value-based NoSQL database.

Contents About Features Installation Links About Fast and advanced, document-based and key-value-based NoSQL database. Features NoSQL database Can be

null 6 Dec 7, 2022
~900 byte minified CSV parser and builder. Smaller when compressed. Built in ESM only.

but-csv ~900 byte minified CSV parser and builder. Smaller when compressed. Built in ESM only. Doesn't care about headers, keyed rows, anything but st

Sam Thorogood 16 Nov 13, 2022
Thin Backend is a Blazing Fast, Universal Web App Backend for Making Realtime Single Page Apps

Website | Documentation About Thin Thin Backend is a blazing fast, universal web app backend for making realtime single page apps. Instead of manually

digitally induced GmbH 1.1k Dec 25, 2022
ConnectNOW - Live web application that allows you to connect with people around the world!

connectNOW Live web application that allows you to connect with people around the world! You can share images, quotes, and anything on your mind! It a

Isha Chaudhry 1 Jan 3, 2022
The Wholesome App. A project that allows you to upload images directly to MongoDB Atlas into your collection, a faster cloud database.

The Wholesome App. A project that allows you to upload images directly to MongoDB Atlas into your collection, a faster cloud database. To upload your cute and wholesome images.

Gourav Singh Rawat 2 Jul 17, 2022
If you are a Slack browser user, this userscript will allow you to auto-redirect without Slack asking if you want to open on the desktop app.

Auto-redirect for browser Slack users If you are a Slack browser user, this userscript will allow you to auto-redirect without Slack asking if you wan

Felipe Santos (he/him) 6 Aug 23, 2022
Allows the DAO to manage Saber pools and for anyone to create new pools without permission

Saber Pools Program Allows the DAO to manage Saber pools and for anyone to create new pools without permission. Setup Instructions Running tests Insta

Saber 7 Sep 4, 2022
Mercurius Auth Plugin

mercurius-auth Mercurius Auth is a plugin for Mercurius that adds configurable Authentication and Authorization support. Features: Define auth directi

null 71 Dec 23, 2022