Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grats

Package Overview
Dependencies
Maintainers
1
Versions
240
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grats - npm Package Compare versions

Comparing version 0.0.0-main-44ac2e23 to 0.0.0-main-5607d067

dist/playground/defaultText.d.ts

44

dist/src/Extractor.js

@@ -391,2 +391,3 @@ "use strict";

var fields = this.collectInputFields(node);
var deprecatedDirective = this.collectDeprecated(node);
this.definitions.push({

@@ -397,3 +398,4 @@ kind: graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION,

name: name,
fields: fields !== null && fields !== void 0 ? fields : undefined
fields: fields !== null && fields !== void 0 ? fields : undefined,
directives: deprecatedDirective == null ? undefined : [deprecatedDirective]
});

@@ -440,2 +442,3 @@ };

var description = this.collectDescription(node.name);
var deprecatedDirective = this.collectDeprecated(node);
return {

@@ -448,3 +451,3 @@ kind: graphql_1.Kind.INPUT_VALUE_DEFINITION,

defaultValue: undefined,
directives: undefined
directives: deprecatedDirective == null ? undefined : [deprecatedDirective]
};

@@ -842,2 +845,3 @@ };

}
var deprecatedDirective = this.collectDeprecated(node);
return {

@@ -850,3 +854,3 @@ kind: graphql_1.Kind.INPUT_VALUE_DEFINITION,

defaultValue: defaultValue || undefined,
directives: []
directives: deprecatedDirective != null ? [deprecatedDirective] : undefined
};

@@ -890,2 +894,3 @@ };

var e_9, _a;
var _b;
// Semantically we only support deriving enums from type aliases that

@@ -913,4 +918,28 @@ // are unions of string literals. However, in the edge case of a union

try {
for (var _b = __values(node.type.types), _c = _b.next(); !_c.done; _c = _b.next()) {
var member = _c.value;
for (var _c = __values(node.type.types), _d = _c.next(); !_d.done; _d = _c.next()) {
var member = _d.value;
// TODO: Complete this feature
if (ts.isTypeReferenceNode(member)) {
if (member.typeName.kind === ts.SyntaxKind.Identifier) {
var symbol = this.ctx.checker.getSymbolAtLocation(member.typeName);
if (((_b = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _b === void 0 ? void 0 : _b.length) === 1) {
var declaration = symbol.declarations[0];
if (ts.isTypeAliasDeclaration(declaration)) {
if (ts.isLiteralTypeNode(declaration.type) &&
ts.isStringLiteral(declaration.type.literal)) {
var deprecatedDirective = this.collectDeprecated(declaration);
var memberDescription = this.collectDescription(declaration.name);
values.push({
kind: graphql_1.Kind.ENUM_VALUE_DEFINITION,
name: this.gqlName(declaration.type.literal, declaration.type.literal.text),
directives: deprecatedDirective ? [deprecatedDirective] : [],
description: memberDescription || undefined,
loc: this.loc(node)
});
continue;
}
}
}
}
}
if (!ts.isLiteralTypeNode(member) ||

@@ -934,3 +963,3 @@ !ts.isStringLiteral(member.literal)) {

try {
if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
if (_d && !_d.done && (_a = _c["return"])) _a.call(_c);
}

@@ -1159,2 +1188,5 @@ finally { if (e_9) throw e_9.error; }

}
else if (ts.isParenthesizedTypeNode(node)) {
return this.collectType(node.type);
}
else if (node.kind === ts.SyntaxKind.StringKeyword) {

@@ -1161,0 +1193,0 @@ return this.gqlNonNullType(node, this.gqlNamedType(node, "String"));

2

package.json
{
"name": "grats",
"version": "0.0.0-main-44ac2e23",
"version": "0.0.0-main-5607d067",
"main": "dist/src/index.js",

@@ -5,0 +5,0 @@ "bin": "dist/src/cli.js",

@@ -22,4 +22,9 @@ # -=[ EXPERIMENTAL PRE ALPHA ]=-

## Example
## Examples
Grats is flexible enough to work with both class-based and functional
approaches to authoring GraphQL types and resolvers.
### Class-Based
```ts

@@ -29,4 +34,4 @@ /** @gqlType */

/** @gqlField */
me(): UserResolver {
return new UserResolver();
me(): User {
return new User();
}

@@ -37,4 +42,4 @@ /**

*/
viewer(): UserResolver {
return new UserResolver();
viewer(): User {
return new User();
}

@@ -45,5 +50,5 @@ }

* A user in our kick-ass system!
* @gqlType User
* @gqlType
*/
class UserResolver {
class User {
/** @gqlField */

@@ -59,4 +64,39 @@ name: string = 'Alice';

Extracts the following GraphQL schema:
### Functional
```ts
/** @gqlType */
export type Query {};
/** @gqlField */
export function me(_: Query): User {
return { name: "Alice" };
}
/**
* @gqlField
* @deprecated Please use `me` instead.
*/
export function viewer(_: Query): User {
return { name: "Alice" };
}
/**
* A user in our kick-ass system!
* @gqlType
*/
type User = {
/** @gqlField */
name: string;
}
/** @gqlField */
export function greeting(user: User, args: { salutation: string }): string {
return `${args.salutation}, ${user.name}`;
}
```
Both of the above examples extract the following GraphQL schema:
```graphql

@@ -84,3 +124,3 @@ type Query {

```sh
```bash
npm install express express-graphql grats

@@ -431,5 +471,5 @@ ```

enum MyEnum {
/** A description of my variant */
/** A description of my value */
OK = "OK",
/** A description of my other variant */
/** A description of my other value */
ERROR = "ERROR"

@@ -436,0 +476,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc