Code Monkey home page Code Monkey logo

nestjs-relay's Introduction

NestJS Relay

A batteries-included toolkit for building Relay-compliant GraphQL APIs with NestJS v7.

npm GitHub Workflow Status Vulnerabilities Coveralls Commitizen friendly

Background

Relay is a Javascript client for GraphQL that is designed for performance and large-scale applications.

Relay provides powerful abstractions for building client applications, however, in order to understand the structure of an application's data, Relay requires that you follow certain conventions when defining your schema.

The three core assumptions that Relay makes about a GraphQL server are that it provides:

  • A mechanism for refetching an object.
  • A description of how to page through connections.
  • Structure around mutations to make them predictable.

Features

  • Build a Relay-compliant GraphQL API without the hassle!

Getting Started

Prerequisites

  • NestJS GraphQL v7
  • Code-first methodology

Installation

# NPM
npm i --save nestjs-relay

# GitHub Release
npm i --save github:rogerballard/nestjs-relay

Peer dependencies:

npm i --save graphql-relay graphql

Guides

Further Reading

For further detail, please see the following resources.

Walkthroughs

Specifications

Contributing

Please see the contribution guidelines and the code of conduct.

nestjs-relay's People

Contributors

chrisfitkin avatar renovate-bot avatar renovate[bot] avatar rogerballard avatar semantic-release-bot avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

nestjs-relay's Issues

Fix build

Describe the bug
The build script does not produce functional umd and es5 modules.

To Reproduce
Steps to reproduce the behavior:

  1. npm run build
  2. See the errors

Expected behavior
A clear and concise description of what you expected to happen.

Additional context
The rollup packages are heavily outdated.

Empty package?

Describe the bug
I've tried installing nestjs-relay through yarn and npm, but in both cases the dist folder appears to be missing?

image

I've tried versions 3.0.1 through 3.0.5, all with the same result...

To Reproduce

  • nest new app
  • yarn add graphql-relay nestjs-relay
  • import { } from 'nestjs-relay';

image

Expected behavior
Files should probably be there :D

If there's anything I can do to help debug I'd love to hear it. Thanks <3

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


The release 4.1.0 on branch master cannot be published as it is out of range.

Based on the releases published on other branches, only versions within the range >=4.0.4 <4.1.0 can be published from branch master.

The following commits are responsible for the invalid release:

  • feat: add async mutation support (#217) (b7f34ac)
  • chore(deps): update dependency husky to v4.3.8 (#186) (de24bbc)
  • chore(deps): update dependency apollo-server-express to v2.19.2 (#182) (5605e70)
  • chore: update package lock (309293a)
  • Merge branch 'master' of github.com:rogerballard/nestjs-relay (aebd092)
  • chore(deps): update dependency lint-staged to v10.5.3 (#187) (c92b150)
  • chore(deps): update coverallsapp/github-action action to v1.1.2 (#180) (f95e8b1)
  • chore(deps): update dependency class-validator to v0.13.1 (#183) (01d33ac)
  • chore(deps): update dependency prettier to v2.2.1 (#188) (58b697b)
  • chore(deps): update dependency semantic-release to v17.3.7 (#190) (84ce537)
  • chore(deps): update dependency typedoc-neo-theme to v1.1.0 (#194) (f754eb3)
  • chore(deps): update dependency typescript to v4.1.3 (#195) (9604ded)
  • chore(deps): update nest monorepo to v7.6.11 (#196) (f94d360)
  • chore(docs): remove incomplete docs (5e27b73)
  • chore(deps): update actions/setup-node action to v2 (#197) (e8c57ec)
  • build(renovate): configure auto merging rules (60e4d8b)
  • chore(deps): update dependency commitizen to v4.2.3 (#184) (6edf115)
  • chore(deps): update dependency rollup to v2.38.4 (#189) (bd2af8d)
  • chore(deps): update dependency ts-jest to v26.5.0 (#191) (79825b4)
  • chore(deps): update dependency typedoc to v0.20.20 (#192) (27c0635)

Those commits should be moved to a valid branch with git merge or git cherry-pick and removed from branch master with git revert or git reset.

A valid branch could be next.

See the workflow configuration documentation for more details.


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

Access to the clientMutationId provided to a mutation

Is your feature request related to a problem? Please describe.
I want my API to cache mutation responses against a clientMutationId.

Describe the solution you'd like
I want access to the clientMutationId provided to a mutation so that if my API sees the same clientMutationId twice, it can be certain it is a duplicate call, and return the cached value.

Perhaps exposed via a ClientMutationId parameter decorator.

Replace TSLint with ESLint

Is your feature request related to a problem? Please describe.
The TSLint package is no longer supported.

Describe the solution you'd like
Configure linting with ESLint.

Start nestJS?

Hello,

Thank you for publishing this project!

"npm install ; npm start" runs rollup but doesn't seem to start the NestJS server. I'm new to NestJS.

How do you start the nestJS server and which port and does /graphql listen on port 4000?

Thanks again!

Plural Identifying Root Field Resolver

Is your feature request related to a problem? Please describe.
This does not implement the pluralIdentifyingRootField functionality available in graphql-relay.

Describe the solution you'd like
Implement the pluralIdentifyingRootField creates a field that accepts a list of non-ID identifiers (like a username) and maps them to their corresponding objects.

Support multiple arguments in a mutation

Is your feature request related to a problem? Please describe.
No.

Describe the solution you'd like
When creating a relay-compliant mutation, I would like the option of adding individual arguments, rather than having to define a separate input type.

Example

@Resolver(Ship)
export class ShipResolver {
  @RelayMutation(() => Ship)
  buildShip(
    @InputArgs() name: string,
  ) {
    return null
  }
}

Should result in the following schema definition:

input BuildShipInput {
  name: String!
  clientMutationId: String
}

type Mutation {
  buildShip(input: BuildShipInput!): BuildShipPayload
}

Connection module

Is your feature request related to a problem? Please describe.
There is a lot of overhead work to build types and tooling to support the Connection specification.

Describe the solution you'd like
A simple set of tools that automate the repeatable steps of building connections.

Contribution Guidelines

Is your feature request related to a problem? Please describe.
I want to contribute to the project, but there aren't any instructions on how to get started, nor is there any information on how to merge my contribution in to the project.

Describe the solution you'd like
Clear and concise instructions on how to configure a development environment. Contribution guidelines that describe the expectations of contributors.

Cleanup non issue

When my account was compromised a spam issue was created in this repo. I sincerely apologize. Cleaning up such issues via script.

Configure CI/CD Pipeline

Describe the solution you'd like

  • View all information in one place:
    • Test result
    • Coverage
    • Releases
  • Automated releases with semantic versioning.
  • Automated publishing to NPM and GitHub Packages.
  • Automated population of the version in the package.json file.

Walkthrough Documentation

Is your feature request related to a problem? Please describe.
It is not clear how to use this library within my project.

Describe the solution you'd like
Clear and concise documentation that outlines the minimal steps required to create a relay-compliant GraphQL API.

Mutation without user-defined Input

Is your feature request related to a problem? Please describe.
The Relay spec requires an input object to be registered in the schema, even when a user-defined input is not required for the mutation.

Describe the solution you'd like
When a mutation is defined without a user-defined input type, there should still be an input type generated in the schema.

@Resolver(Ship)
export class ShipResolver {
  @RelayMutation(() => Ship)
  buildShip() {
    return null
  }
}

Should result in the following schema:

input BuildShipInput {
  clientMutationId: String
}

type Mutation {
  buildShip(input: BuildShipInput!): BuildShipPayload
}

Add more fields on "Connection" type

Currently, the "Connection" type has only 2 standard fields, "Edge" and "PageInfo", we need a way to add more fields and its resolvers to it like "totalCount", maybe also in the "Edge" type as well.

Nodes field on connection types

Is your feature request related to a problem? Please describe.
I am unable to extend the generated Connection type.

Describe the solution you'd like
The option to extend the Connection type to add custom properties, such as a nodes field.

Cache dependencies during workflows

Is your feature request related to a problem? Please describe.
The projects dependencies do not need to be redownloaded every single push to master.

Describe the solution you'd like
Use a github action for cashing the installed dependencies so that future builds are faster.

Remove dependency on util

Is your feature request related to a problem? Please describe.
The util dependency is only used for one function to check a string.

Describe the solution you'd like
Implement that function within nestjs-relay so that there is one less peer dependency

Public API Documentation

Is your feature request related to a problem? Please describe.
It is not clear what each exposed class/argument/function does within this library.

Describe the solution you'd like
Clear and concise API documentation that describes the purpose of each class/argument/function.

Connection usage with additional arguments

Is your feature request related to a problem? Please describe.
It is not clear from the documentation how I can provide additional arguments to a method decorated with ResolveConnectionField.

Describe the solution you'd like
An example in the documentation that shows how to implement additional arguments.

Add validation to ConnectionArgs

Is your feature request related to a problem? Please describe.
The ConnectionArgs implementation does not require either first or last to be provided.

Describe the solution you'd like
Implement validation on the ConnectionArgs to require one of first or last.

Question: How does this library intend the use of the ID scalar?

First of all, thanks for the great package :)

When I integrated nestjs-relay in our existing application, there was an issue, where all ID fields had to be of type ResolvedGlobalId (as far as I understood). All places where I used a simple @Field(type => ID) with e.g. a string type (though I think it doesn't matter), the schema builder complained about the ID type being defined multiple times with different types. However with only ResolvedGlobalId-IDs the schema builder accepts the schema.

Is this intended and should all IDs be converted to ResolvedGlobalIds or am I missing something...

Thanks in advance πŸ˜„

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • fix(deps): update dependency graphql-tools to v6.2.6
  • chore(deps): update coverallsapp/github-action action to v1.2.5
  • chore(deps): update dependency commitizen to v4.3.0
  • chore(deps): update dependency prettier to v2.8.8
  • chore(deps): update dependency tsconfig-paths to v3.15.0
  • fix(deps): update dependency @nestjs/graphql to v7.11.0
  • fix(deps): update dependency graphql to v15.8.0
  • fix(deps): update dependency graphql-relay to ^0.10.0 (graphql-relay, @types/graphql-relay)
  • fix(deps): update dependency reflect-metadata to ^0.2.0
  • chore(deps): update actions/checkout action to v4
  • chore(deps): update actions/setup-node action to v4
  • chore(deps): update coverallsapp/github-action action to v2
  • chore(deps): update dependency @types/node to v20
  • chore(deps): update dependency apollo-server-express to v3
  • chore(deps): update dependency eslint to v9
  • chore(deps): update dependency eslint-config-prettier to v9
  • chore(deps): update dependency husky to v9
  • chore(deps): update dependency lint-staged to v15
  • chore(deps): update dependency prettier to v3
  • chore(deps): update dependency rimraf to v5
  • chore(deps): update dependency rollup to v4
  • chore(deps): update dependency supertest to v7
  • chore(deps): update dependency tsconfig-paths to v4
  • chore(deps): update dependency typescript to v5
  • chore(deps): update jest monorepo to v29 (major) (@types/jest, jest, jest-config, ts-jest)
  • chore(deps): update semantic-release monorepo (major) (@semantic-release/changelog, @semantic-release/git)
  • chore(deps): update typescript-eslint monorepo to v7 (major) (@typescript-eslint/eslint-plugin, @typescript-eslint/parser)
  • fix(deps): update dependency @nestjs/graphql to v12
  • fix(deps): update dependency graphql to v16
  • fix(deps): update nest monorepo to v10 (major) (@nestjs/common, @nestjs/platform-express, @nestjs/testing)
  • πŸ” Create all rate-limited PRs at once πŸ”

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/development.yml
  • actions/checkout v2
  • actions/setup-node v2
  • coverallsapp/github-action v1.1.2
  • actions/checkout v2
  • cycjimmy/semantic-release-action v2
npm
package.json
  • @nestjs/common ^7.6.5
  • @nestjs/core ^7.2.0
  • @nestjs/graphql ^7.7.0
  • graphql ^15.4.0
  • graphql-relay ^0.6.0
  • graphql-tools ^6.2.4
  • reflect-metadata ^0.1.13
  • @commitlint/cli 11.0.0
  • @commitlint/config-conventional 11.0.0
  • @nestjs/platform-express 7.6.11
  • @nestjs/testing 7.6.11
  • @semantic-release/changelog 5.0.1
  • @semantic-release/git 9.0.0
  • @types/graphql-relay 0.6.0
  • @types/jest 26.0.15
  • @types/node 10.17.35
  • @types/supertest 2.0.10
  • @typescript-eslint/eslint-plugin 4.3.0
  • @typescript-eslint/parser 4.3.0
  • apollo-server-express 2.19.2
  • class-validator 0.13.1
  • commitizen 4.2.3
  • cz-conventional-changelog 3.3.0
  • eslint 7.10.0
  • eslint-config-prettier 6.13.0
  • husky 4.3.8
  • jest 26.4.2
  • jest-config 26.4.2
  • lint-staged 10.5.3
  • prettier 2.2.1
  • rimraf 3.0.2
  • rollup 2.38.4
  • rollup-plugin-typescript2 0.27.3
  • semantic-release 17.3.7
  • snyk 1.406.0
  • supertest 5.0.0
  • ts-jest 26.5.0
  • tsconfig-paths 3.9.0
  • typescript 4.0.3
  • node >=6.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

Long term plans, used in production ?

Hi,

This looks like just what I am looking for :-)

I presume the test folder is a workable application?

Is this something that you are just doing a POC for or its something you intend to use in production?

I would like to adopt it but just wondering the longevity of the project and your long terms ideas / plans.

Thanks in advance.

Connection helper functions

Is your feature request related to a problem? Please describe.
The connection helper functions included in graphql-relay are limited in their functionality.

Describe the solution you'd like
More powerful connection helper functionality that follows similar conventions to NestJS.

Remove dependencies from bundle

Is your feature request related to a problem? Please describe.
This library depends on the packages installed in the library, rather than my project.

Describe the solution you'd like
A clear and concise description of what you want to happen.
Configure the library to look for peer dependencies.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.