
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
@tsed/graphql
Advanced tools
GraphQL package for Ts.ED framework, based on Apollo-server-express and Type-graphql
A package of Ts.ED framework. See website: https://tsed.io/tutorials/graphql.html
GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data. GraphQL provides a complete and understandable description of the data in your API, gives clients the power to ask for exactly what they need and nothing more, makes it easier to evolve APIs over time, and enables powerful developer tools.
Currently, @tsed/typegraphql allows you to configure a graphql server in your project.
This package use apollo-server-express to create GraphQL server and type-graphql
for the decorators.
To begin, install the TypeGraphQL module for TS.ED:
npm install --save @tsed/typegraphql type-graphql graphql@15
npm install --save apollo-datasource apollo-datasource-rest apollo-server-express
npm install --save-dev apollo-server-testing
Now, we can configure the Ts.ED server by importing @tsed/typegraphql in your Server:
import {Configuration} from "@tsed/common";
import "@tsed/typegraphql";
@Configuration({
graphql: {
server1: {
resolvers: []
}
}
})
export class Server {}
TypeGraphQlService let you to retrieve an instance of ApolloServer.
import {Service, AfterRoutesInit} from "@tsed/common";
import {TypeGraphQLService} from "@tsed/typegraphql";
import {ApolloServer} from "apollo-server-express";
@Service()
export class UsersService implements AfterRoutesInit {
private server: ApolloServer;
@Inject()
typeGraphQLService: TypeGraphQLService;
$afterRoutesInit() {
this.server = this.typeGraphQLService.get("server1");
}
}
For more information about ApolloServer look his documentation here;
We want to get equivalent of this type described in SDL:
type Recipe {
id: ID!
title: String!
description: String
creationDate: Date!
ingredients: [String!]!
}
So we create the Recipe class with all properties and types:
class Recipe {
id: string;
title: string;
description?: string;
creationDate: Date;
ingredients: string[];
}
Then we decorate the class and it properties with decorators:
import {ObjectType, ID, Field} from "type-graphql";
@ObjectType()
export class Recipe {
@Field((type) => ID)
id: string;
@Field()
title: string;
@Field({nullable: true})
description?: string;
@Field()
creationDate: Date;
@Field((type) => [String])
ingredients: string[];
}
The detailed rules when to use nullable, array and others are described in fields and types docs.
After that we want to create typical crud queries and mutation. To do that we create the resolver (controller) class that will have injected RecipeService in constructor:
import {Resolver, Query, Arg, Args, Mutation, Authorized, Ctx} from "type-graphql";
import {ResolverService} from "@tsed/typegraphql";
import {Recipe} from "../types/Recipe";
import {RecipeService} from "../services/RecipeService";
import {RecipeNotFoundError} from "../errors/RecipeNotFoundError";
@ResolverService(Recipe)
export class RecipeResolver {
constructor(private recipeService: RecipeService) {}
@Query((returns) => Recipe)
async recipe(@Arg("id") id: string) {
const recipe = await this.recipeService.findById(id);
if (recipe === undefined) {
throw new RecipeNotFoundError(id);
}
return recipe;
}
@Query((returns) => [Recipe])
recipes(@Args() {skip, take}: RecipesArgs) {
return this.recipeService.findAll({skip, take});
}
}
Please read contributing guidelines here
Thank you to all our backers! 🙏 [Become a backer]
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]
The MIT License (MIT)
Copyright (c) 2016 - 2018 Romain Lenzotti
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
GraphQL package for Ts.ED framework, based on Apollo-server-express and Type-graphql
The npm package @tsed/graphql receives a total of 72 weekly downloads. As such, @tsed/graphql popularity was classified as not popular.
We found that @tsed/graphql demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.