Working through a directives api

This commit is contained in:
Tim Griesser 2018-11-12 14:54:29 -05:00
parent f7b00a0980
commit 2b8b5c0902
24 changed files with 805 additions and 396 deletions

View File

@ -5,7 +5,8 @@
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/node_modules": true
"**/node_modules": true,
"**/dist/**": true
},
"typescript.tsdk": "node_modules/typescript/lib"
}

View File

@ -34,22 +34,22 @@ The schema requires that an Object named `Query` be provided at the top-level.
const Query = GQLiteralObject("Query", (t) => {
t.field("account", "Account", {
args: {
name: GQLiteralArg("String", {
name: t.stringArg({
description:
"Providing the name of the account holder will search for accounts matching that name",
}),
status: GQLiteralArg("StatusEnum"),
status: t.fieldArg("StatusEnum"),
},
});
t.field("accountsById", "Account", {
list: true,
args: {
ids: GQLiteralArg("Int", { list: true }),
ids: t.intArg({ list: true }),
},
});
t.field("accounts", "AccountConnection", {
args: {
limit: GQLiteralArg("Int", { required: true }),
limit: t.intArg({ required: true }),
},
});
});

View File

@ -1,3 +1,8 @@
### ---
### This file was autogenerated by gqliteral
### Do not edit the contents directly
### ---
type Launch {
id: ID!
isBooked: Boolean!

View File

@ -11,6 +11,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"gqliteral": "^0.1.0",
"apollo-datasource": "^0.2.0",
"apollo-datasource-rest": "^0.2.0",
"apollo-server": "2.2.0-alpha.2",

View File

@ -299,15 +299,11 @@ export interface GeneratedSchema {
unions: GeneratedUnions;
scalars: GeneratedScalars;
interfaces: GeneratedInterfaces;
// For simplicity in autocomplete:
availableInputTypes:
| BaseScalarNames
allInputTypes:
| Extract<keyof GeneratedInputObjects, string>
| Extract<keyof GeneratedEnums, string>
| Extract<keyof GeneratedScalars, string>;
availableOutputTypes:
| BaseScalarNames
allOutputTypes:
| Extract<keyof GeneratedObjects, string>
| Extract<keyof GeneratedEnums, string>
| Extract<keyof GeneratedUnions, string>

View File

View File

@ -1,3 +1,8 @@
### ---
### This file was autogenerated by gqliteral
### Do not edit the contents directly
### ---
"""A comment about an entry, submitted by a user"""
type Comment {
"""The text of the comment"""

View File

@ -1,9 +1,8 @@
/**
* This file is autogenerated. Do not edit directly.
* This file is automatically generated by gqliteral
* Do not make changes directly
*/
export type BaseScalarNames = "String" | "Int" | "Float" | "ID" | "Boolean";
export interface Generated_Type_Query_Field_currentUser {
returnType:
| Generated_Type_User["backingType"]
@ -334,15 +333,11 @@ export interface GeneratedSchema {
unions: GeneratedUnions;
scalars: GeneratedScalars;
interfaces: GeneratedInterfaces;
// For simplicity in autocomplete:
availableInputTypes:
| BaseScalarNames
allInputTypes:
| Extract<keyof GeneratedInputObjects, string>
| Extract<keyof GeneratedEnums, string>
| Extract<keyof GeneratedScalars, string>;
availableOutputTypes:
| BaseScalarNames
allOutputTypes:
| Extract<keyof GeneratedObjects, string>
| Extract<keyof GeneratedEnums, string>
| Extract<keyof GeneratedUnions, string>

View File

@ -1,6 +1,8 @@
{
"name": "gqliteral-githunt-api",
"dependencies": {
"gqliteral": "^0.1.0",
"graphql": "^14.0.2",
"apollo-server": "2.2.0-alpha.2",
"githunt-api": "apollographql/GitHunt-API.git"
},

View File

@ -5,8 +5,20 @@ const {
GQLiteralObject,
GQLiteralArg,
GQLiteralAbstractType,
GQLiteralDirective,
} = require("gqliteral");
exports.CacheControl = GQLiteralDirective("cacheControl", (t) => {
t.int("maxAge");
t.field("scope", "CacheControlScope");
t.locations("OBJECT", "FIELD_DEFINITION");
});
exports.CacheControlScope = GQLiteralEnum("CacheControlScope", [
"PUBLIC",
"PRIVATE",
]);
exports.FeedType = GQLiteralEnum("FeedType", (t) => {
t.description("A list of options for the sort order of the feed");
t.member("HOT", {
@ -49,6 +61,14 @@ exports.Query = GQLiteralObject("Query", (t) => {
t.field("currentUser", "User", {
description:
"Return the currently logged in user, or null if nobody is logged in",
directives: [
{
name: "cacheControl",
args: {
scope: "PRIVATE",
},
},
],
});
});
@ -102,9 +122,10 @@ const CommonFields = GQLiteralAbstractType((t) => {
exports.Comment = GQLiteralObject("Comment", (t) => {
t.description("A comment about an entry, submitted by a user");
// t.directive("@cacheControl(maxAge: 240)");
t.directive("cacheControl", { maxAge: 240 });
t.mix(CommonFields);
t.float("createdAt", {
property: "created_at",
description: "A timestamp of when the comment was posted",
});
t.string("content", {
@ -123,7 +144,7 @@ exports.Vote = GQLiteralObject("Vote", (t) => {
// # Information about a GitHub repository submitted to GitHunt
exports.Entry = GQLiteralObject("Entry", (t) => {
t.mix(CommonFields);
// t.directive(@cacheControl(maxAge: 240))
t.directive("cacheControl", { maxAge: 240 });
t.field("repository", "Repository", {
description: "Information about the repository from GitHub",
});
@ -133,7 +154,10 @@ exports.Entry = GQLiteralObject("Entry", (t) => {
t.int("score", {
description: "The score of this repository, upvotes - downvotes",
});
t.float("hotScore", { description: "The hot score of this repository" });
t.float("hotScore", {
property: "hot_score",
description: "The hot score of this repository",
});
t.field("comments", "Comment", {
list: true,
args: {
@ -153,7 +177,9 @@ exports.Repository = GQLiteralObject("Repository", (t) => {
A repository object from the GitHub API. This uses the exact field names returned by the
GitHub API for simplicity, even though the convention for GraphQL is usually to camel case.
`);
// t.directive @cacheControl(maxAge:240)
t.directive("cacheControl", {
maxAge: 240,
});
t.string("name", {
description: "Just the name of the repository, e.g. GitHunt-API",
});
@ -184,7 +210,9 @@ exports.User = GQLiteralObject("User", (t) => {
t.description(
"A user object from the GitHub API. This uses the exact field names returned from the GitHub API."
);
// t.directive @cacheControl(maxAge:240)
t.directive("cacheControl", {
maxAge: 240,
});
t.string("login", { description: "The name of the user, e.g. apollostack" });
t.string("avatar_url", {
description:

View File

@ -5,6 +5,7 @@
"start": "ts-node-dev --no-notify --respawn ./src"
},
"dependencies": {
"gqliteral": "^0.1.0",
"graphql": "^14.0.2",
"apollo-server": "^2.2.0",
"ts-node": "^7.0.1",

View File

@ -1,18 +1,19 @@
/**
* This file is autogenerated. Do not edit directly.
* This file is automatically generated by gqliteral
* Do not make changes directly
*/
import * as swapi from "./gqliteral/backingTypes";
export type BaseScalarNames = "String" | "Int" | "Float" | "ID" | "Boolean";
export interface Generated_Interface_Character_Fields {
appearsIn: {
returnType:
| GeneratedEnums["Episode"][]
| PromiseLike<GeneratedEnums["Episode"][]>
| PromiseLike<GeneratedEnums["Episode"]>[];
args: {};
args: {
id: string;
};
};
friends: {
returnType:
@ -138,15 +139,11 @@ export interface GeneratedSchema {
unions: GeneratedUnions;
scalars: GeneratedScalars;
interfaces: GeneratedInterfaces;
// For simplicity in autocomplete:
availableInputTypes:
| BaseScalarNames
allInputTypes:
| Extract<keyof GeneratedInputObjects, string>
| Extract<keyof GeneratedEnums, string>
| Extract<keyof GeneratedScalars, string>;
availableOutputTypes:
| BaseScalarNames
allOutputTypes:
| Extract<keyof GeneratedObjects, string>
| Extract<keyof GeneratedEnums, string>
| Extract<keyof GeneratedUnions, string>

View File

@ -1,4 +1,4 @@
import { GQLiteralInterface } from "gqliteral";
import { GQLiteralInterface, GQLiteralArg } from "gqliteral";
import { getFriends } from "../data";
export const Character = GQLiteralInterface("Character", (t) => {
@ -15,6 +15,9 @@ export const Character = GQLiteralInterface("Character", (t) => {
list: true,
description: "Which movies they appear in.",
property: "appears_in",
args: {
id: GQLiteralArg("ID", { required: true }),
},
});
t.resolveType((character) => character.type);
});

View File

@ -1,7 +1,12 @@
### ---
### This file was autogenerated by gqliteral
### Do not edit the contents directly
### ---
"""A character in the Star Wars Trilogy"""
interface Character {
"""Which movies they appear in."""
appearsIn: [Episode!]!
appearsIn(id: ID!): [Episode!]!
"""The friends of the character, or an empty list if they have none."""
friends: [Character!]!
@ -16,7 +21,7 @@ interface Character {
"""A mechanical creature in the Star Wars universe."""
type Droid implements Character {
"""Which movies they appear in."""
appearsIn: [Episode!]!
appearsIn(id: ID!): [Episode!]!
"""The friends of the character, or an empty list if they have none."""
friends: [Character!]!
@ -45,7 +50,7 @@ enum Episode {
"""A humanoid creature in the Star Wars universe."""
type Human implements Character {
"""Which movies they appear in."""
appearsIn: [Episode!]!
appearsIn(id: ID!): [Episode!]!
"""The friends of the character, or an empty list if they have none."""
friends: [Character!]!

View File

@ -123,6 +123,10 @@
"@types/express-serve-static-core" "*"
"@types/serve-static" "*"
"@types/handlebars@4.0.39":
version "4.0.39"
resolved "https://registry.yarnpkg.com/@types/handlebars/-/handlebars-4.0.39.tgz#961fb54db68030890942e6aeffe9f93a957807bd"
"@types/long@^4.0.0":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.0.tgz#719551d2352d301ac8b81db732acb6bdc28dbdef"
@ -453,7 +457,7 @@ async-retry@^1.2.1:
dependencies:
retry "0.12.0"
async@^2.1.4, async@^2.5.0:
async@^2.1.4, async@^2.5.0, async@^2.6.0:
version "2.6.1"
resolved "https://registry.yarnpkg.com/async/-/async-2.6.1.tgz#b245a23ca71930044ec53fa46aa00a3e87c6a610"
dependencies:
@ -750,6 +754,13 @@ callsites@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/callsites/-/callsites-2.0.0.tgz#06eb84f00eea413da86affefacbffb36093b3c50"
camel-case@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/camel-case/-/camel-case-3.0.0.tgz#ca3c3688a4e9cf3a4cda777dc4dcbc713249cf73"
dependencies:
no-case "^2.2.0"
upper-case "^1.1.1"
camelcase-keys@^2.0.0:
version "2.1.0"
resolved "http://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz#308beeaffdf28119051efa1d932213c91b8f92e7"
@ -782,6 +793,14 @@ caseless@~0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc"
chalk@2.4.1, chalk@^2.0.0, chalk@^2.0.1, chalk@^2.4.1:
version "2.4.1"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e"
dependencies:
ansi-styles "^3.2.1"
escape-string-regexp "^1.0.5"
supports-color "^5.3.0"
chalk@^1.1.3:
version "1.1.3"
resolved "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98"
@ -792,13 +811,28 @@ chalk@^1.1.3:
strip-ansi "^3.0.0"
supports-color "^2.0.0"
chalk@^2.0.0, chalk@^2.0.1, chalk@^2.4.1:
version "2.4.1"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e"
change-case@3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/change-case/-/change-case-3.0.2.tgz#fd48746cce02f03f0a672577d1d3a8dc2eceb037"
dependencies:
ansi-styles "^3.2.1"
escape-string-regexp "^1.0.5"
supports-color "^5.3.0"
camel-case "^3.0.0"
constant-case "^2.0.0"
dot-case "^2.1.0"
header-case "^1.0.0"
is-lower-case "^1.1.0"
is-upper-case "^1.1.0"
lower-case "^1.1.1"
lower-case-first "^1.0.0"
no-case "^2.3.2"
param-case "^2.1.0"
pascal-case "^2.0.0"
path-case "^2.1.0"
sentence-case "^2.1.0"
snake-case "^2.1.0"
swap-case "^1.1.0"
title-case "^2.1.0"
upper-case "^1.1.1"
upper-case-first "^1.1.0"
chownr@^1.1.1:
version "1.1.1"
@ -853,7 +887,7 @@ collection-visit@^1.0.0:
map-visit "^1.0.0"
object-visit "^1.0.0"
color-convert@^1.9.0:
color-convert@^1.9.0, color-convert@^1.9.1:
version "1.9.3"
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8"
dependencies:
@ -863,10 +897,43 @@ color-name@1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"
color-name@^1.0.0:
version "1.1.4"
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
color-string@^1.5.2:
version "1.5.3"
resolved "https://registry.yarnpkg.com/color-string/-/color-string-1.5.3.tgz#c9bbc5f01b58b5492f3d6857459cb6590ce204cc"
dependencies:
color-name "^1.0.0"
simple-swizzle "^0.2.2"
color@3.0.x:
version "3.0.0"
resolved "https://registry.yarnpkg.com/color/-/color-3.0.0.tgz#d920b4328d534a3ac8295d68f7bd4ba6c427be9a"
dependencies:
color-convert "^1.9.1"
color-string "^1.5.2"
colornames@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/colornames/-/colornames-1.1.1.tgz#f8889030685c7c4ff9e2a559f5077eb76a816f96"
colors@1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b"
colors@^1.2.1:
version "1.3.2"
resolved "https://registry.yarnpkg.com/colors/-/colors-1.3.2.tgz#2df8ff573dfbf255af562f8ce7181d6b971a359b"
colorspace@1.1.x:
version "1.1.1"
resolved "https://registry.yarnpkg.com/colorspace/-/colorspace-1.1.1.tgz#9ac2491e1bc6f8fb690e2176814f8d091636d972"
dependencies:
color "3.0.x"
text-hex "1.0.x"
combined-stream@^1.0.6, combined-stream@~1.0.6:
version "1.0.7"
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.7.tgz#2d1d24317afb8abe95d6d2c0b07b57813539d828"
@ -877,6 +944,10 @@ commander@~2.17.1:
version "2.17.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf"
common-tags@1.8.0:
version "1.8.0"
resolved "https://registry.yarnpkg.com/common-tags/-/common-tags-1.8.0.tgz#8e3153e542d4a39e9b10554434afaaf98956a937"
component-emitter@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6"
@ -889,6 +960,13 @@ console-control-strings@^1.0.0, console-control-strings@~1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e"
constant-case@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/constant-case/-/constant-case-2.0.0.tgz#4175764d389d3fa9c8ecd29186ed6005243b6a46"
dependencies:
snake-case "^2.1.0"
upper-case "^1.1.1"
content-disposition@0.5.2:
version "0.5.2"
resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.2.tgz#0cf68bb9ddf5f2be7961c3a85178cb85dba78cb4"
@ -1072,6 +1150,14 @@ detect-newline@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-2.1.0.tgz#f41f1c10be4b00e87b5f13da680759f2c5bfd3e2"
diagnostics@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/diagnostics/-/diagnostics-1.1.1.tgz#cab6ac33df70c9d9a727490ae43ac995a769b22a"
dependencies:
colorspace "1.1.x"
enabled "1.0.x"
kuler "1.0.x"
dicer@0.2.5:
version "0.2.5"
resolved "https://registry.yarnpkg.com/dicer/-/dicer-0.2.5.tgz#5996c086bb33218c812c090bddc09cd12facb70f"
@ -1089,6 +1175,12 @@ domexception@^1.0.1:
dependencies:
webidl-conversions "^4.0.2"
dot-case@^2.1.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/dot-case/-/dot-case-2.1.1.tgz#34dcf37f50a8e93c2b3bca8bb7fb9155c7da3bee"
dependencies:
no-case "^2.2.0"
dynamic-dedupe@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/dynamic-dedupe/-/dynamic-dedupe-0.2.0.tgz#50f7c28684831ecf1c170aab67a1d5311cdd76ce"
@ -1106,10 +1198,20 @@ ee-first@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
enabled@1.0.x:
version "1.0.2"
resolved "http://registry.npmjs.org/enabled/-/enabled-1.0.2.tgz#965f6513d2c2d1c5f4652b64a2e3396467fc2f93"
dependencies:
env-variable "0.0.x"
encodeurl@~1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59"
env-variable@0.0.x:
version "0.0.5"
resolved "https://registry.yarnpkg.com/env-variable/-/env-variable-0.0.5.tgz#913dd830bef11e96a039c038d4130604eba37f88"
error-ex@^1.2.0:
version "1.3.2"
resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf"
@ -1325,12 +1427,20 @@ fast-levenshtein@~2.0.4:
version "2.0.6"
resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917"
fast-safe-stringify@^2.0.4:
version "2.0.6"
resolved "https://registry.yarnpkg.com/fast-safe-stringify/-/fast-safe-stringify-2.0.6.tgz#04b26106cc56681f51a044cfc0d76cf0008ac2c2"
fb-watchman@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/fb-watchman/-/fb-watchman-2.0.0.tgz#54e9abf7dfa2f26cd9b1636c588c1afc05de5d58"
dependencies:
bser "^2.0.0"
fecha@^2.3.3:
version "2.3.3"
resolved "http://registry.npmjs.org/fecha/-/fecha-2.3.3.tgz#948e74157df1a32fd1b12c3a3c3cdcb6ec9d96cd"
filename-regex@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26"
@ -1516,10 +1626,40 @@ globals@^9.18.0:
version "9.18.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a"
gqliteral@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/gqliteral/-/gqliteral-0.1.0.tgz#b001728a57bbaeeba15f9d4c875675734bb278eb"
dependencies:
graphql-codegen-compiler "0.13.0"
graphql-codegen-core "0.13.0"
graceful-fs@^4.1.11, graceful-fs@^4.1.2:
version "4.1.15"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00"
graphql-codegen-compiler@0.13.0:
version "0.13.0"
resolved "https://registry.yarnpkg.com/graphql-codegen-compiler/-/graphql-codegen-compiler-0.13.0.tgz#5d7787849ce5b109f2ca7af681f428a1633c6b39"
dependencies:
"@types/handlebars" "4.0.39"
change-case "3.0.2"
common-tags "1.8.0"
graphql-codegen-core "0.13.0"
handlebars "4.0.12"
moment "2.22.2"
graphql-codegen-core@0.13.0:
version "0.13.0"
resolved "https://registry.yarnpkg.com/graphql-codegen-core/-/graphql-codegen-core-0.13.0.tgz#c288b2e263ea73724215c10712116f05c7ce02cd"
dependencies:
chalk "2.4.1"
change-case "3.0.2"
common-tags "1.8.0"
graphql-tag "2.10.0"
graphql-tools "4.0.3"
ts-log "2.1.3"
winston "3.1.0"
graphql-extensions@0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/graphql-extensions/-/graphql-extensions-0.3.0.tgz#49e3a77986e34d0dc0af0c07fc51e48dcdec8b0c"
@ -1530,11 +1670,11 @@ graphql-subscriptions@^1.0.0:
dependencies:
iterall "^1.2.1"
graphql-tag@^2.9.2:
graphql-tag@2.10.0, graphql-tag@^2.9.2:
version "2.10.0"
resolved "https://registry.yarnpkg.com/graphql-tag/-/graphql-tag-2.10.0.tgz#87da024be863e357551b2b8700e496ee2d4353ae"
graphql-tools@^4.0.0:
graphql-tools@4.0.3, graphql-tools@^4.0.0:
version "4.0.3"
resolved "https://registry.yarnpkg.com/graphql-tools/-/graphql-tools-4.0.3.tgz#23b5cb52c519212b1b2e4630a361464396ad264b"
dependencies:
@ -1554,7 +1694,7 @@ growly@^1.2.0, growly@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081"
handlebars@^4.0.3:
handlebars@4.0.12, handlebars@^4.0.3:
version "4.0.12"
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.12.tgz#2c15c8a96d46da5e266700518ba8cb8d919d5bc5"
dependencies:
@ -1630,6 +1770,13 @@ has@^1.0.1:
dependencies:
function-bind "^1.1.1"
header-case@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/header-case/-/header-case-1.0.1.tgz#9535973197c144b09613cd65d317ef19963bd02d"
dependencies:
no-case "^2.2.0"
upper-case "^1.1.3"
home-or-tmp@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8"
@ -1748,6 +1895,10 @@ is-arrayish@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d"
is-arrayish@^0.3.1:
version "0.3.2"
resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.3.2.tgz#4574a2ae56f7ab206896fb431eaeed066fdf8f03"
is-buffer@^1.1.5:
version "1.1.6"
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be"
@ -1850,6 +2001,12 @@ is-glob@^2.0.0, is-glob@^2.0.1:
dependencies:
is-extglob "^1.0.0"
is-lower-case@^1.1.0:
version "1.1.3"
resolved "https://registry.yarnpkg.com/is-lower-case/-/is-lower-case-1.1.3.tgz#7e147be4768dc466db3bfb21cc60b31e6ad69393"
dependencies:
lower-case "^1.1.0"
is-number@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f"
@ -1904,6 +2061,12 @@ is-typedarray@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"
is-upper-case@^1.1.0:
version "1.1.2"
resolved "https://registry.yarnpkg.com/is-upper-case/-/is-upper-case-1.1.2.tgz#8d0b1fa7e7933a1e58483600ec7d9661cbaf756f"
dependencies:
upper-case "^1.1.0"
is-utf8@^0.2.0:
version "0.2.1"
resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72"
@ -2418,6 +2581,12 @@ kleur@^2.0.1:
version "2.0.2"
resolved "https://registry.yarnpkg.com/kleur/-/kleur-2.0.2.tgz#b704f4944d95e255d038f0cb05fb8a602c55a300"
kuler@1.0.x:
version "1.0.1"
resolved "https://registry.yarnpkg.com/kuler/-/kuler-1.0.1.tgz#ef7c784f36c9fb6e16dd3150d152677b2b0228a6"
dependencies:
colornames "^1.1.1"
lcid@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/lcid/-/lcid-1.0.0.tgz#308accafa0bc483a3867b4b6f2b9506251d1b835"
@ -2537,6 +2706,16 @@ lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.4:
version "4.17.11"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
logform@^1.9.1:
version "1.10.0"
resolved "https://registry.yarnpkg.com/logform/-/logform-1.10.0.tgz#c9d5598714c92b546e23f4e78147c40f1e02012e"
dependencies:
colors "^1.2.1"
fast-safe-stringify "^2.0.4"
fecha "^2.3.3"
ms "^2.1.1"
triple-beam "^1.2.0"
long@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28"
@ -2554,6 +2733,16 @@ loud-rejection@^1.0.0:
currently-unhandled "^0.4.1"
signal-exit "^3.0.0"
lower-case-first@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/lower-case-first/-/lower-case-first-1.0.2.tgz#e5da7c26f29a7073be02d52bac9980e5922adfa1"
dependencies:
lower-case "^1.1.2"
lower-case@^1.1.0, lower-case@^1.1.1, lower-case@^1.1.2:
version "1.1.4"
resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-1.1.4.tgz#9a2cabd1b9e8e0ae993a4bf7d5875c39c42e8eac"
lru-cache@^4.0.1, lru-cache@^4.1.3:
version "4.1.3"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.3.tgz#a1175cf3496dfc8436c156c334b4955992bce69c"
@ -2744,6 +2933,10 @@ mkdirp@0.x, mkdirp@^0.5.0, mkdirp@^0.5.1:
dependencies:
minimist "0.0.8"
moment@2.22.2:
version "2.22.2"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.2.tgz#3c257f9839fc0e93ff53149632239eb90783ff66"
ms@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
@ -2788,6 +2981,12 @@ negotiator@0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9"
no-case@^2.2.0, no-case@^2.3.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/no-case/-/no-case-2.3.2.tgz#60b813396be39b3f1288a4c1ed5d1e7d28b464ac"
dependencies:
lower-case "^1.1.1"
node-emoji@^1.4.1:
version "1.8.1"
resolved "https://registry.yarnpkg.com/node-emoji/-/node-emoji-1.8.1.tgz#6eec6bfb07421e2148c75c6bba72421f8530a826"
@ -2964,6 +3163,10 @@ once@^1.3.0, once@^1.4.0:
dependencies:
wrappy "1"
one-time@0.0.4:
version "0.0.4"
resolved "https://registry.yarnpkg.com/one-time/-/one-time-0.0.4.tgz#f8cdf77884826fe4dff93e3a9cc37b1e4480742e"
optimist@^0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686"
@ -3025,6 +3228,12 @@ p-try@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3"
param-case@^2.1.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/param-case/-/param-case-2.1.1.tgz#df94fd8cf6531ecf75e6bef9a0858fbc72be2247"
dependencies:
no-case "^2.2.0"
parse-glob@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/parse-glob/-/parse-glob-3.0.4.tgz#b2c376cfb11f35513badd173ef0bb6e3a388391c"
@ -3048,10 +3257,23 @@ parseurl@~1.3.2:
version "1.3.2"
resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.2.tgz#fc289d4ed8993119460c156253262cdc8de65bf3"
pascal-case@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/pascal-case/-/pascal-case-2.0.1.tgz#2d578d3455f660da65eca18ef95b4e0de912761e"
dependencies:
camel-case "^3.0.0"
upper-case-first "^1.1.0"
pascalcase@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14"
path-case@^2.1.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/path-case/-/path-case-2.1.1.tgz#94b8037c372d3fe2906e465bb45e25d226e8eea5"
dependencies:
no-case "^2.2.0"
path-exists@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b"
@ -3247,7 +3469,7 @@ readable-stream@1.1.x:
isarray "0.0.1"
string_decoder "~0.10.x"
readable-stream@^2.0.1, readable-stream@^2.0.6:
readable-stream@^2.0.1, readable-stream@^2.0.6, readable-stream@^2.3.6:
version "2.3.6"
resolved "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf"
dependencies:
@ -3461,6 +3683,13 @@ send@0.16.2:
range-parser "~1.2.0"
statuses "~1.4.0"
sentence-case@^2.1.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/sentence-case/-/sentence-case-2.1.1.tgz#1f6e2dda39c168bf92d13f86d4a918933f667ed4"
dependencies:
no-case "^2.2.0"
upper-case-first "^1.1.2"
serve-static@1.13.2:
version "1.13.2"
resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.13.2.tgz#095e8472fd5b46237db50ce486a43f4b86c6cec1"
@ -3514,6 +3743,12 @@ signal-exit@^3.0.0, signal-exit@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"
simple-swizzle@^0.2.2:
version "0.2.2"
resolved "https://registry.yarnpkg.com/simple-swizzle/-/simple-swizzle-0.2.2.tgz#a4da6b635ffcccca33f70d17cb92592de95e557a"
dependencies:
is-arrayish "^0.3.1"
sisteransi@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-0.1.1.tgz#5431447d5f7d1675aac667ccd0b865a4994cb3ce"
@ -3522,6 +3757,12 @@ slash@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"
snake-case@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/snake-case/-/snake-case-2.1.0.tgz#41bdb1b73f30ec66a04d4e2cad1b76387d4d6d9f"
dependencies:
no-case "^2.2.0"
snapdragon-node@^2.0.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b"
@ -3630,6 +3871,10 @@ sshpk@^1.7.0:
safer-buffer "^2.0.2"
tweetnacl "~0.14.0"
stack-trace@0.0.x:
version "0.0.10"
resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.10.tgz#547c70b347e8d32b4e108ea1a2a159e5fdde19c0"
stack-utils@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-1.0.1.tgz#d4f33ab54e8e38778b0ca5cfd3b3afb12db68620"
@ -3751,6 +3996,13 @@ supports-color@^5.3.0:
dependencies:
has-flag "^3.0.0"
swap-case@^1.1.0:
version "1.1.2"
resolved "https://registry.yarnpkg.com/swap-case/-/swap-case-1.1.2.tgz#c39203a4587385fad3c850a0bd1bcafa081974e3"
dependencies:
lower-case "^1.1.1"
upper-case "^1.1.1"
symbol-observable@^1.0.4:
version "1.2.0"
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804"
@ -3781,10 +4033,21 @@ test-exclude@^4.2.1:
read-pkg-up "^1.0.1"
require-main-filename "^1.0.1"
text-hex@1.0.x:
version "1.0.0"
resolved "https://registry.yarnpkg.com/text-hex/-/text-hex-1.0.0.tgz#69dc9c1b17446ee79a92bf5b884bb4b9127506f5"
throat@^4.0.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/throat/-/throat-4.1.0.tgz#89037cbc92c56ab18926e6ba4cbb200e15672a6a"
title-case@^2.1.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/title-case/-/title-case-2.1.1.tgz#3e127216da58d2bc5becf137ab91dae3a7cd8faa"
dependencies:
no-case "^2.2.0"
upper-case "^1.0.3"
tmpl@1.0.x:
version "1.0.4"
resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.4.tgz#23640dd7b42d00433911140820e5cf440e521dd1"
@ -3836,6 +4099,10 @@ trim-right@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003"
triple-beam@^1.2.0, triple-beam@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/triple-beam/-/triple-beam-1.3.0.tgz#a595214c7298db8339eeeee083e4d10bd8cb8dd9"
ts-jest@^23.10.4:
version "23.10.4"
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-23.10.4.tgz#a7a953f55c9165bcaa90ff91014a178e87fe0df8"
@ -3849,6 +4116,10 @@ ts-jest@^23.10.4:
semver "^5.5"
yargs-parser "10.x"
ts-log@2.1.3:
version "2.1.3"
resolved "https://registry.yarnpkg.com/ts-log/-/ts-log-2.1.3.tgz#9e30aca1baffe7693a2e4142b8f07ecb01cb8340"
ts-node-dev@^1.0.0-pre.30:
version "1.0.0-pre.30"
resolved "https://registry.yarnpkg.com/ts-node-dev/-/ts-node-dev-1.0.0-pre.30.tgz#11446f273d8adee9fa4b8de6661ef5885abb5431"
@ -3936,6 +4207,16 @@ unset-value@^1.0.0:
has-value "^0.3.1"
isobject "^3.0.0"
upper-case-first@^1.1.0, upper-case-first@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/upper-case-first/-/upper-case-first-1.1.2.tgz#5d79bedcff14419518fd2edb0a0507c9b6859115"
dependencies:
upper-case "^1.1.1"
upper-case@^1.0.3, upper-case@^1.1.0, upper-case@^1.1.1, upper-case@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/upper-case/-/upper-case-1.1.3.tgz#f6b4501c2ec4cdd26ba78be7222961de77621598"
uri-js@^4.2.2:
version "4.2.2"
resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.2.2.tgz#94c540e1ff772956e2299507c010aea6c8838eb0"
@ -4053,6 +4334,27 @@ wide-align@^1.1.0:
dependencies:
string-width "^1.0.2 || 2"
winston-transport@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/winston-transport/-/winston-transport-4.2.0.tgz#a20be89edf2ea2ca39ba25f3e50344d73e6520e5"
dependencies:
readable-stream "^2.3.6"
triple-beam "^1.2.0"
winston@3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/winston/-/winston-3.1.0.tgz#80724376aef164e024f316100d5b178d78ac5331"
dependencies:
async "^2.6.0"
diagnostics "^1.1.1"
is-stream "^1.1.0"
logform "^1.9.1"
one-time "0.0.4"
readable-stream "^2.3.6"
stack-trace "0.0.x"
triple-beam "^1.3.0"
winston-transport "^4.2.0"
wordwrap@~0.0.2:
version "0.0.3"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107"

View File

@ -4,6 +4,7 @@
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",
"description": "Scalable, strongly typed GraphQL schema development",
"scripts": {
"dev": "tsc -w",
"test": "jest"

View File

@ -30,11 +30,14 @@ import {
isObjectType,
isOutputType,
isUnionType,
DirectiveLocationEnum,
GraphQLDirective,
isDirective,
} from "graphql";
import { GQLiteralTypeWrapper } from "./definitions";
import * as Types from "./types";
import suggestionList, { propertyFieldResolver } from "./utils";
import { GQLiteralAbstract } from "./objects";
import { GQLiteralAbstract, GQLiteralDirectiveType } from "./objects";
const isPromise = (val: any): val is Promise<any> =>
Boolean(val && typeof val.then === "function");
@ -62,9 +65,32 @@ const SCALARS: Record<string, GraphQLScalarType> = {
* circular references at this step, while fields will guard for it during lazy evaluation.
*/
export class SchemaBuilder {
/**
* Used to check for circular references.
*/
protected buildingTypes = new Set();
/**
* The "final type" map contains all types as they are built.
*/
protected finalTypeMap: Record<string, GraphQLNamedType> = {};
/**
* The "defined type" map keeps track of all of the types that were
* defined directly as `GraphQL*Type` objects, so we don't accidentally
* overwrite any.
*/
protected definedTypeMap: Record<string, GraphQLNamedType> = {};
/**
* The "pending type" map keeps track of all types that
*/
protected pendingTypeMap: Record<string, GQLiteralTypeWrapper> = {};
protected pendingDirectiveMap: Record<
string,
GQLiteralDirectiveType<any>
> = {};
protected directiveMap: Record<string, GraphQLDirective> = {};
protected directiveUseMap: {
[K in DirectiveLocationEnum]?: Types.DirectiveUse
} = {};
constructor(
protected schemaConfig: Pick<
@ -84,7 +110,15 @@ export class SchemaBuilder {
}
}
getFinalTypeMap(): Record<string, GraphQLNamedType> {
addDirective(directiveDef: GQLiteralDirectiveType<any> | GraphQLDirective) {
if (isDirective(directiveDef)) {
this.directiveMap[directiveDef.name] = directiveDef;
} else {
this.pendingDirectiveMap[directiveDef.name] = directiveDef;
}
}
getFinalTypeMap(): Types.BuildTypes {
Object.keys(this.pendingTypeMap).forEach((key) => {
// If we've already constructed the type by this point,
// via circular dependency resolution don't worry about building it.
@ -94,7 +128,22 @@ export class SchemaBuilder {
this.finalTypeMap[key] = this.getOrBuildType(key);
this.buildingTypes.clear();
});
return this.finalTypeMap;
Object.keys(this.pendingDirectiveMap).forEach((key) => {});
return {
types: this.finalTypeMap,
directives: {
definitions: [],
uses: {},
hasUses: false,
},
};
}
directiveType(config: Types.DirectiveTypeConfig) {
return new GraphQLDirective({
name: config.name,
locations: [],
});
}
inputObjectType(config: Types.InputTypeConfig): GraphQLInputObjectType {
@ -147,8 +196,6 @@ export class SchemaBuilder {
fields: () => this.buildObjectFields(config),
resolveType,
description,
// astNode?: Maybe<InterfaceTypeDefinitionNode>;
// extensionASTNodes?: Maybe<ReadonlyArray<InterfaceTypeExtensionNode>>;
});
}
@ -262,6 +309,7 @@ export class SchemaBuilder {
switch (field.item) {
case Types.NodeType.MIX:
throw new Error("TODO");
break;
case Types.NodeType.MIX_ABSTRACT:
this.mixAbstractOuput(
typeConfig,
@ -289,6 +337,7 @@ export class SchemaBuilder {
switch (field.item) {
case Types.NodeType.MIX:
throw new Error("TODO");
break;
case Types.NodeType.MIX_ABSTRACT:
this.mixAbstractInput(
typeConfig,
@ -360,7 +409,6 @@ export class SchemaBuilder {
args: this.buildArgs(fieldConfig.args || {}, typeConfig),
// subscribe?: GraphQLFieldResolver<TSource, TContext, TArgs>;
// deprecationReason?: Maybe<string>;
// astNode?: Maybe<FieldDefinitionNode>;
};
}

View File

@ -5,6 +5,7 @@ import {
lexicographicSortSchema,
printSchema,
GraphQLScalarType,
GraphQLObjectType,
} from "graphql";
import * as Types from "./types";
import {
@ -15,8 +16,14 @@ import {
GQLiteralInputObjectType,
GQLiteralAbstract,
GQLiteralUnionType,
GQLiteralDirectiveType,
} from "./objects";
import { enumShorthandMembers, buildTypes } from "./utils";
import {
enumShorthandMembers,
buildTypes,
dedent,
addDirectives,
} from "./utils";
import { typegen } from "./typegen";
/**
@ -148,10 +155,7 @@ export function GQLiteralEnum<
export function GQLiteralInputObject<
GenTypes = GQLiteralGen,
TypeName extends string = any
>(
name: TypeName,
fn: (arg: GQLiteralInputObjectType<GenTypes, TypeName>) => void
) {
>(name: TypeName, fn: (arg: GQLiteralInputObjectType<GenTypes>) => void) {
const factory = new GQLiteralInputObjectType<GenTypes>(name);
fn(factory);
return new GQLiteralTypeWrapper(name, factory);
@ -185,7 +189,7 @@ export function GQLiteralAbstractType<GenTypes = GQLiteralGen>(
* `__Arg` methods: `fieldArg`, `stringArg`, `intArg`, etc.
*/
export function GQLiteralArg<GenTypes = GQLiteralGen>(
type: Types.AllInputTypes<GenTypes>,
type: Types.AllInputTypes<GenTypes> | Types.BaseScalars,
options?: Types.ArgOpts
): Readonly<Types.ArgDefinition> {
// This isn't wrapped for now because it's not a named type, it's really
@ -196,6 +200,28 @@ export function GQLiteralArg<GenTypes = GQLiteralGen>(
};
}
/**
* Defines a directive that can be used by the schema. Directives should
* be rarely used, as they only function for external consumers of the schema.
*/
export function GQLiteralDirective<
GenTypes = GQLiteralGen,
DirectiveName extends string = any
>(
name: DirectiveName,
config:
| Types.DirectiveConfig<GenTypes, DirectiveName>
| ((arg: GQLiteralDirectiveType<GenTypes>) => void)
) {
const directive = new GQLiteralDirectiveType<GenTypes>(name);
if (typeof config === "function") {
config(directive);
} else {
directive.locations(...config.locations);
}
return directive;
}
/**
* Defines the GraphQL schema, by combining the GraphQL types defined
* by the GQLiteral layer or any manually defined GraphQLType objects.
@ -204,16 +230,17 @@ export function GQLiteralArg<GenTypes = GQLiteralGen>(
* root query type.
*/
export function GQLiteralSchema(options: Types.SchemaConfig) {
const typeMap = buildTypes(options.types, options);
const { types: typeMap, directives } = buildTypes(options.types, options);
if (!isObjectType(typeMap["Query"])) {
throw new Error("Missing a Query type");
}
const schema = new GraphQLSchema({
query: typeMap["Query"] as any,
mutation: typeMap["Mutation"] as any,
subscription: typeMap["Subscription"] as any,
query: typeMap["Query"] as Types.Maybe<GraphQLObjectType>,
mutation: typeMap["Mutation"] as Types.Maybe<GraphQLObjectType>,
subscription: typeMap["Subscription"] as Types.Maybe<GraphQLObjectType>,
directives: directives.definitions,
types: Object.keys(typeMap).reduce((result: GraphQLNamedType[], key) => {
result.push(typeMap[key]);
return result;
@ -224,11 +251,20 @@ export function GQLiteralSchema(options: Types.SchemaConfig) {
// schema definition and/or generated types.
if (process.env.NODE_ENV !== "production") {
const sortedSchema = lexicographicSortSchema(schema);
const generatedSchema = printSchema(sortedSchema);
const generatedSchema = addDirectives(
printSchema(sortedSchema),
directives
);
const fs = require("fs");
const header = dedent(`
### ---
### This file was autogenerated by gqliteral
### Do not edit the contents directly
### ---
`);
fs.writeFile(
options.definitionFilePath,
generatedSchema,
[header, generatedSchema].join("\n\n"),
(err: Error | null) => {
if (err) {
return console.error(err);

View File

@ -8,4 +8,5 @@ export {
GQLiteralSchema,
GQLiteralScalar,
GQLiteralAbstractType,
GQLiteralDirective,
} from "./definitions";

View File

@ -6,9 +6,8 @@ import {
GraphQLUnionType,
GraphQLEnumType,
GraphQLIsTypeOfFn,
GraphQLInputFieldConfigMap,
GraphQLFieldConfigMap,
GraphQLResolveInfo,
DirectiveLocationEnum,
} from "graphql";
import { addMix, dedent } from "./utils";
import { SchemaBuilder } from "./builder";
@ -23,7 +22,7 @@ export type GQLiteralNamedType =
| GQLiteralObjectType<any, any>
| GQLiteralInterfaceType<any, any>
| GQLiteralUnionType<any, any>
| GQLiteralInputObjectType<any, any>;
| GQLiteralInputObjectType<any>;
/**
* Backing type for an enum member.
@ -35,6 +34,7 @@ export class GQLiteralEnumType<GenTypes = GQLiteralGen> {
this.typeConfig = {
name,
members: [],
directives: [],
};
}
@ -85,6 +85,17 @@ export class GQLiteralEnumType<GenTypes = GQLiteralGen> {
this.typeConfig.description = dedent(description);
}
/**
* Should be used very rarely, adds a directive directly to the
* enum definition - for interpretation by other schema consumers.
*/
directive(name: string, args?: Record<string, any>) {
this.typeConfig.directives.push({
name,
args: args || {},
});
}
/**
* Internal use only. Creates the configuration to create
* the GraphQL named type.
@ -108,6 +119,7 @@ export class GQLiteralUnionType<
this.typeConfig = {
name,
members: [],
directives: [],
};
}
@ -136,11 +148,21 @@ export class GQLiteralUnionType<
* the default implementation will call `isTypeOf` on each implementing
* Object type.
*/
resolveType(typeResolver: Types.ResolveType<GenTypes, TypeName>) {
// @ts-ignore
resolveType(typeResolver: Types.TypeResolver<GenTypes, TypeName>) {
this.typeConfig.resolveType = typeResolver;
}
/**
* Should be used very rarely, adds a directive directly to the
* union definition - for interpretation by other schema consumers.
*/
directive(name: string, args?: Record<string, any>) {
this.typeConfig.directives.push({
name,
args: args || {},
});
}
/**
* Internal use only. Creates the configuration to create
* the GraphQL named type.
@ -152,27 +174,22 @@ export class GQLiteralUnionType<
abstract class FieldsArgs<GenTypes = GQLiteralGen> {
idArg(options?: Types.ArgOpts) {
// @ts-ignore
return GQLiteralArg<GenTypes>("ID", options);
}
intArg(options?: Types.ArgOpts) {
// @ts-ignore
return GQLiteralArg<GenTypes>("Int", options);
}
floatArg(options?: Types.ArgOpts) {
// @ts-ignore
return GQLiteralArg<GenTypes>("Float", options);
}
boolArg(options?: Types.ArgOpts) {
// @ts-ignore
return GQLiteralArg<GenTypes>("Bool", options);
return GQLiteralArg<GenTypes>("Boolean", options);
}
stringArg(options?: Types.ArgOpts) {
// @ts-ignore
return GQLiteralArg<GenTypes>("String", options);
}
@ -196,6 +213,7 @@ export class GQLiteralObjectType<
name,
fields: [],
interfaces: [],
directives: [],
};
}
@ -217,7 +235,6 @@ export class GQLiteralObjectType<
name: FieldName,
options?: Types.OutputFieldOpts<GenTypes, TypeName, FieldName>
) {
// @ts-ignore
this.field(name, "ID", options);
}
@ -228,7 +245,6 @@ export class GQLiteralObjectType<
name: FieldName,
options?: Types.OutputFieldOpts<GenTypes, TypeName, FieldName>
) {
// @ts-ignore
this.field(name, "Int", options);
}
@ -239,7 +255,6 @@ export class GQLiteralObjectType<
name: FieldName,
options?: Types.OutputFieldOpts<GenTypes, TypeName, FieldName>
) {
// @ts-ignore
this.field(name, "Float", options);
}
@ -250,7 +265,6 @@ export class GQLiteralObjectType<
name: FieldName,
options?: Types.OutputFieldOpts<GenTypes, TypeName, FieldName>
) {
// @ts-ignore
this.field(name, "String", options);
}
@ -261,7 +275,6 @@ export class GQLiteralObjectType<
name: FieldName,
options?: Types.OutputFieldOpts<GenTypes, TypeName, FieldName>
) {
// @ts-ignore
this.field(name, "Boolean", options);
}
@ -270,7 +283,7 @@ export class GQLiteralObjectType<
*/
field<FieldName extends string>(
name: FieldName,
type: Types.AllOutputTypes<GenTypes>,
type: Types.AllOutputTypes<GenTypes> | Types.BaseScalars,
options?: Types.OutputFieldOpts<GenTypes, TypeName, FieldName>
) {
this.typeConfig.fields.push({
@ -322,10 +335,12 @@ export class GQLiteralObjectType<
* At this point the type will not change, but the resolver,
* defaultValue, property, or description fields can.
*/
modify<FieldName extends string>(
modify<FieldName extends Types.ObjectTypeFields<GenTypes, TypeName>>(
field: FieldName,
options?: Types.ModifyFieldOpts<GenTypes, TypeName, FieldName>
) {}
) {
throw new Error("TODO");
}
/**
* Supply the default field resolver for all members of this type
@ -339,6 +354,17 @@ export class GQLiteralObjectType<
this.typeConfig.defaultResolver = resolverFn;
}
/**
* Should be used very rarely, adds a directive directly to the
* object definition - for interpretation by other schema consumers.
*/
directive(name: string, args?: Record<string, any>) {
this.typeConfig.directives.push({
name,
args: args || {},
});
}
/**
* Internal use only. Creates the configuration to create
* the GraphQL named type.
@ -361,6 +387,7 @@ export class GQLiteralInterfaceType<
this.typeConfig = {
name,
fields: [],
directives: [],
};
}
@ -382,7 +409,6 @@ export class GQLiteralInterfaceType<
name: FieldName,
options?: Types.OutputFieldOpts<GenTypes, TypeName, FieldName>
) {
// @ts-ignore
this.field(name, "ID", options);
}
@ -393,7 +419,6 @@ export class GQLiteralInterfaceType<
name: FieldName,
options?: Types.OutputFieldOpts<GenTypes, TypeName, FieldName>
) {
// @ts-ignore
this.field(name, "Int", options);
}
@ -404,7 +429,6 @@ export class GQLiteralInterfaceType<
name: FieldName,
options?: Types.OutputFieldOpts<GenTypes, TypeName, FieldName>
) {
// @ts-ignore
this.field(name, "Float", options);
}
@ -415,7 +439,6 @@ export class GQLiteralInterfaceType<
name: FieldName,
options?: Types.OutputFieldOpts<GenTypes, TypeName, FieldName>
) {
// @ts-ignore
this.field(name, "String", options);
}
@ -426,7 +449,6 @@ export class GQLiteralInterfaceType<
name: FieldName,
options?: Types.OutputFieldOpts<GenTypes, TypeName, FieldName>
) {
// @ts-ignore
this.field(name, "Boolean", options);
}
@ -435,7 +457,7 @@ export class GQLiteralInterfaceType<
*/
field<FieldName extends string>(
name: FieldName,
type: Types.AllOutputTypes<GenTypes>,
type: Types.AllOutputTypes<GenTypes> | Types.BaseScalars,
options?: Types.OutputFieldOpts<GenTypes, TypeName, FieldName>
) {
this.typeConfig.fields.push({
@ -460,11 +482,21 @@ export class GQLiteralInterfaceType<
* the default implementation will call `isTypeOf` on each implementing
* Object type.
*/
resolveType(typeResolver: Types.ResolveType<GenTypes, TypeName>) {
// @ts-ignore
resolveType(typeResolver: Types.TypeResolver<GenTypes, TypeName>) {
this.typeConfig.resolveType = typeResolver;
}
/**
* Should be used very rarely, adds a directive directly to the
* interface definition - for interpretation by other schema consumers.
*/
directive(name: string, args?: Record<string, any>) {
this.typeConfig.directives.push({
name,
args: args || {},
});
}
/**
* Internal use only. Creates the configuration to create
* the GraphQL named type.
@ -474,16 +506,14 @@ export class GQLiteralInterfaceType<
}
}
export class GQLiteralInputObjectType<
GenTypes = GQLiteralGen,
TypeName extends string = any
> {
export class GQLiteralInputObjectType<GenTypes = GQLiteralGen> {
protected typeConfig: Types.InputTypeConfig;
constructor(name: string) {
this.typeConfig = {
name,
fields: [],
directives: [],
};
}
@ -492,9 +522,8 @@ export class GQLiteralInputObjectType<
*/
id<FieldName extends string>(
name: FieldName,
options?: Types.OutputFieldOpts<GenTypes, TypeName, FieldName>
options?: Types.InputFieldOpts
) {
// @ts-ignore
this.field(name, "ID", options);
}
@ -503,9 +532,8 @@ export class GQLiteralInputObjectType<
*/
int<FieldName extends string>(
name: FieldName,
options?: Types.OutputFieldOpts<GenTypes, TypeName, FieldName>
options?: Types.InputFieldOpts
) {
// @ts-ignore
this.field(name, "Int", options);
}
@ -514,9 +542,8 @@ export class GQLiteralInputObjectType<
*/
float<FieldName extends string>(
name: FieldName,
options?: Types.OutputFieldOpts<GenTypes, TypeName, FieldName>
options?: Types.InputFieldOpts
) {
// @ts-ignore
this.field(name, "Float", options);
}
@ -525,9 +552,8 @@ export class GQLiteralInputObjectType<
*/
string<FieldName extends string>(
name: FieldName,
options?: Types.OutputFieldOpts<GenTypes, TypeName, FieldName>
options?: Types.InputFieldOpts
) {
// @ts-ignore
this.field(name, "String", options);
}
@ -536,9 +562,8 @@ export class GQLiteralInputObjectType<
*/
boolean<FieldName extends string>(
name: FieldName,
options?: Types.OutputFieldOpts<GenTypes, TypeName, FieldName>
options?: Types.InputFieldOpts
) {
// @ts-ignore
this.field(name, "Boolean", options);
}
@ -547,8 +572,8 @@ export class GQLiteralInputObjectType<
*/
field<FieldName extends string>(
name: FieldName,
type: Types.AllInputTypes<GenTypes>,
options?: Types.OutputFieldOpts<GenTypes, TypeName, FieldName>
type: Types.AllInputTypes<GenTypes> | Types.BaseScalars,
options?: Types.InputFieldOpts
) {
this.typeConfig.fields.push({
item: Types.NodeType.FIELD,
@ -564,6 +589,17 @@ export class GQLiteralInputObjectType<
this.typeConfig.description = dedent(description);
}
/**
* Should be used very rarely, adds a directive directly to the
* input object definition - for interpretation by other schema consumers.
*/
directive(name: string, args?: Record<string, any>) {
this.typeConfig.directives.push({
name,
args: args || {},
});
}
/**
* Internal use only. Creates the configuration to create
* the GraphQL named type.
@ -596,7 +632,6 @@ export class GQLiteralAbstract<GenTypes> extends FieldsArgs {
name: FieldName,
options?: Types.AbstractFieldOpts<GenTypes, FieldName>
) {
// @ts-ignore
this.field(name, "ID", options);
}
@ -607,7 +642,6 @@ export class GQLiteralAbstract<GenTypes> extends FieldsArgs {
name: FieldName,
options?: Types.AbstractFieldOpts<GenTypes, FieldName>
) {
// @ts-ignore
this.field(name, "Int", options);
}
@ -618,7 +652,6 @@ export class GQLiteralAbstract<GenTypes> extends FieldsArgs {
name: FieldName,
options?: Types.AbstractFieldOpts<GenTypes, FieldName>
) {
// @ts-ignore
this.field(name, "Float", options);
}
@ -629,7 +662,6 @@ export class GQLiteralAbstract<GenTypes> extends FieldsArgs {
name: FieldName,
options?: Types.AbstractFieldOpts<GenTypes, FieldName>
) {
// @ts-ignore
this.field(name, "String", options);
}
@ -640,7 +672,6 @@ export class GQLiteralAbstract<GenTypes> extends FieldsArgs {
name: FieldName,
options?: Types.AbstractFieldOpts<GenTypes, FieldName>
) {
// @ts-ignore
this.field(name, "Boolean", options);
}
@ -649,7 +680,7 @@ export class GQLiteralAbstract<GenTypes> extends FieldsArgs {
*/
field<FieldName extends string>(
name: FieldName,
type: Types.AllInputTypes<GenTypes>,
type: Types.AllInputTypes<GenTypes> | Types.BaseScalars,
options?: Types.AbstractFieldOpts<GenTypes, FieldName>
) {
this.typeConfig.fields.push({
@ -663,3 +694,92 @@ export class GQLiteralAbstract<GenTypes> extends FieldsArgs {
return this.typeConfig;
}
}
export class GQLiteralDirectiveType<GenTypes = GQLiteralGen> {
protected typeConfig: Types.DirectiveTypeConfig;
constructor(readonly name: string) {
this.typeConfig = {
name,
locations: [],
args: [],
};
}
description(description: string) {
this.typeConfig.description = dedent(description);
}
locations(...location: DirectiveLocationEnum[]) {
this.typeConfig.locations.push(...location);
}
/**
* Add an ID field type to the object schema.
*/
id<FieldName extends string>(
name: FieldName,
options?: Types.InputFieldOpts
) {
this.field(name, "ID", options);
}
/**
* Add an Int field type to the object schema.
*/
int<FieldName extends string>(
name: FieldName,
options?: Types.InputFieldOpts
) {
this.field(name, "Int", options);
}
/**
* Add a Float field type to the object schema.
*/
float<FieldName extends string>(
name: FieldName,
options?: Types.InputFieldOpts
) {
this.field(name, "Float", options);
}
/**
* Add a String field type to the object schema.
*/
string<FieldName extends string>(
name: FieldName,
options?: Types.InputFieldOpts
) {
this.field(name, "String", options);
}
/**
* Add a Boolean field type to the object schema.
*/
boolean<FieldName extends string>(
name: FieldName,
options?: Types.InputFieldOpts
) {
this.field(name, "Boolean", options);
}
/**
* Adds a new field to the input object type
*/
field<FieldName extends string>(
name: FieldName,
type: Types.AllInputTypes<GenTypes> | Types.BaseScalars,
options?: Types.InputFieldOpts
) {
this.typeConfig.args.push({
name,
type,
...options,
});
}
buildType(builder: SchemaBuilder) {
return builder.directiveType(this.typeConfig);
}
}

View File

@ -80,7 +80,8 @@ export const makeTypes = (
};
const tmpl = `
/**
* This file is autogenerated. Do not edit directly.
* This file is automatically generated by gqliteral
* Do not make changes directly
*/
${headerPrefix.join("\n")}
@ -91,8 +92,6 @@ export const makeTypes = (
.replace(/.tsx?$/, "")}"`;
})}
export type BaseScalarNames = "String" | "Int" | "Float" | "ID" | "Boolean";
${map(context.interfaces, (i) => {
const typeName = `${prefix}_Interface_${i.name}`;
@ -172,7 +171,7 @@ export const makeTypes = (
}
export interface ${prefix}InputObjects {
${map(context.inputTypes, (i) => {
return `${i.name}: any;`;
return `${i.name}: any; // TODO!!`;
})}
}
export interface ${prefix}Objects {
@ -187,13 +186,11 @@ export const makeTypes = (
unions: ${prefix}Unions;
scalars: ${prefix}Scalars;
interfaces: ${prefix}Interfaces;
// For simplicity in autocomplete:
availableInputTypes: BaseScalarNames
allInputTypes:
| Extract<keyof ${prefix}InputObjects, string>
| Extract<keyof ${prefix}Enums, string>
| Extract<keyof ${prefix}Scalars, string>;
availableOutputTypes: BaseScalarNames
allOutputTypes:
| Extract<keyof ${prefix}Objects, string>
| Extract<keyof ${prefix}Enums, string>
| Extract<keyof ${prefix}Unions, string>

View File

@ -2,9 +2,10 @@ import {
GraphQLFieldResolver,
GraphQLScalarTypeConfig,
GraphQLNamedType,
GraphQLTypeResolver,
GraphQLIsTypeOfFn,
GraphQLResolveInfo,
DirectiveLocationEnum,
GraphQLDirective,
} from "graphql";
import { GQLiteralAbstract } from "./objects";
import { GQLiteralTypegenOptions } from "./typegen";
@ -19,6 +20,12 @@ export enum NodeType {
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
export type BaseScalars = "String" | "Int" | "Float" | "ID" | "Boolean";
export type MaybePromise<T> = Promise<T> | T;
export type Maybe<T> = T | null;
export type MixDef = {
item: NodeType.MIX;
typeName: string;
@ -62,6 +69,25 @@ export interface EnumMemberConfig {
description?: string;
}
export interface BuildTypes {
types: Record<string, GraphQLNamedType>;
directives: BuildTypesDirectives;
}
export interface BuildTypesDirectives {
definitions: GraphQLDirective[];
uses: { [K in DirectiveLocationEnum]?: DirectiveUse };
hasUses: boolean;
}
export interface DirectiveUse {
location: DirectiveLocationEnum;
typeName: string;
args: [];
argName?: string;
fieldName?: string;
}
/**
* When you're mixing types/partials, you can pick or omit
* fields from the types you're mixing in.
@ -93,20 +119,20 @@ export interface CommonOpts {
* object definition
*/
description?: string;
/**
* Whether the field / property is even considered to be defined on the schema.
* Useful if you want to feature-flag
*/
availableIf?: any;
/**
* Info about a field deprecation. Formatted as a string and provided with the
* deprecated directive on field/enum types and as a comment on input fields.
*/
deprecation?: string | DeprecationInfo;
/**
* Any directives for the type
* Any directives for the field or argument
*/
directives?: any[];
directives?: DirectiveOption[];
}
export interface DirectiveOption {
name: string;
args: Record<string, any>;
}
export interface FieldOpts extends CommonOpts {
@ -144,6 +170,13 @@ export type ArgDefinition = Readonly<
}
>;
export type DirectiveArgDefinition = Readonly<
ArgOpts & {
name: string;
type: any; // TODO: Make type safe
}
>;
export type OutputFieldArgs = Record<string, ArgDefinition>;
export interface OutputFieldOpts<
@ -178,7 +211,7 @@ export interface AbstractFieldOpts<GenTypes, FieldName> extends FieldOpts {}
export type ModifyFieldOpts<GenTypes, TypeName, FieldName> = Omit<
OutputFieldOpts<GenTypes, TypeName, FieldName>,
"args" | "list" | "listItemNullable" | "nullable" | "availableIf"
"args" | "list" | "listItemNullable" | "nullable"
>;
export interface InputFieldOpts extends FieldOpts {}
@ -199,7 +232,7 @@ interface HasFields {
}
interface HasDirectives {
directives: any[];
directives: DirectiveOption[];
}
interface Named {
@ -232,29 +265,34 @@ export interface Nullability {
nullability?: NullabilityConfig;
}
export interface EnumTypeConfig extends Named, SharedTypeConfig {
export interface EnumTypeConfig extends Named, HasDirectives, SharedTypeConfig {
members: EnumDefType[];
}
export interface UnionTypeConfig extends Named, SharedTypeConfig {
export interface UnionTypeConfig
extends Named,
HasDirectives,
SharedTypeConfig {
members: UnionDefType[];
/**
* Optionally provide a custom type resolver function. If one is not provided,
* the default implementation will call `isTypeOf` on each implementing
* Object type.
*/
resolveType?: GraphQLTypeResolver<any, any>;
resolveType?: TypeResolver<any, any>;
}
export interface InputTypeConfig
extends Named,
HasFields,
HasDirectives,
SharedTypeConfig,
Nullability {}
export interface ObjectTypeConfig
extends Named,
HasFields,
HasDirectives,
SharedTypeConfig,
Nullability,
DefaultResolver {
@ -273,9 +311,16 @@ export interface AbstractTypeConfig {
fields: FieldConfig[];
}
export interface DirectiveTypeConfig extends Named {
description?: string;
locations: DirectiveLocationEnum[];
args: DirectiveArgDefinition[];
}
export interface InterfaceTypeConfig
extends Named,
HasFields,
HasDirectives,
SharedTypeConfig,
Nullability,
DefaultResolver {
@ -284,7 +329,7 @@ export interface InterfaceTypeConfig
* the default implementation will call `isTypeOf` on each implementing
* Object type.
*/
resolveType?: GraphQLTypeResolver<any, any>;
resolveType?: TypeResolver<any, any>;
}
export interface SchemaConfig extends Nullability, DefaultResolver {
@ -299,13 +344,9 @@ export interface SchemaConfig extends Nullability, DefaultResolver {
*/
definitionFilePath: string | false;
/**
* Generates the types for intellisense/typescript
* Generates the types for Intellisense/TypeScript
*/
typeGeneration?: GQLiteralTypegenOptions;
/**
* Forces type-safety by not falling back to strings
*/
forceTypeSafety?: boolean;
}
export type NullabilityConfig = {
@ -371,19 +412,15 @@ export type NullabilityConfig = {
inputListItem?: boolean;
};
export type GetTypeFn = (t: string) => GraphQLNamedType;
/**
* Generated type helpers:
*/
export type ResolveType<GenTypes, TypeName> = (
root: RootValue<GenTypes, TypeName>
) => InterfaceName<GenTypes, TypeName>;
type GenTypesFieldsShape = Record<
string,
{
returnType: any;
args: any;
}
>;
export type TypeResolver<GenTypes, TypeName> = (
root: RootValue<GenTypes, TypeName>,
context: ContextValue<GenTypes>,
info: GraphQLResolveInfo
) => MaybePromise<Maybe<InterfaceName<GenTypes, TypeName>>>;
/**
* Helpers for handling the generated schema
@ -396,8 +433,8 @@ export type GenTypesShape = {
inputObjects: Record<string, any>;
unions: Record<string, any>;
scalars: Record<string, any>;
availableInputTypes: string;
availableOutputTypes: string;
allInputTypes: string;
allOutputTypes: string;
};
export type OutputNames<GenTypes> = GenTypes extends GenTypesShape
@ -418,6 +455,15 @@ export type UnionName<GenTypes> = GenTypes extends GenTypesShape
? Extract<keyof GenTypes["unions"], string>
: never;
export type ObjectTypeFields<
GenTypes,
TypeName
> = GenTypes extends GenTypesShape
? TypeName extends keyof GenTypes["objects"]
? Extract<keyof GenTypes["objects"][TypeName]["fields"], string>
: never
: unknown;
export type EnumMembers<
GenTypes,
EnumName extends string
@ -440,18 +486,18 @@ export type InputObjectTypeDef<
? TypeName extends keyof GenTypes["inputObjects"]
? GenTypes["inputObjects"][TypeName]
: never
: string;
: unknown;
export type AllInterfaces<GenTypes> = GenTypes extends GenTypesShape
? Extract<keyof GenTypes["interfaces"], string>
: never;
export type AllInputTypes<GenTypes> = GenTypes extends GenTypesShape
? GenTypes["availableInputTypes"]
? GenTypes["allInputTypes"]
: never;
export type AllOutputTypes<GenTypes> = GenTypes extends GenTypesShape
? GenTypes["availableOutputTypes"]
? GenTypes["allOutputTypes"]
: never;
export type RootValue<GenTypes, TypeName> = GenTypes extends GenTypesShape
@ -497,3 +543,8 @@ export type ResultValue<
: never
: never
: never;
export type DirectiveConfig<GenTypes, DirectiveName> = {
locations: DirectiveLocationEnum[];
args?: [];
};

View File

@ -1,8 +1,15 @@
import { GraphQLFieldResolver, GraphQLNamedType, isNamedType } from "graphql";
import {
GraphQLFieldResolver,
isNamedType,
parse,
visit,
print,
isDirective,
} from "graphql";
import { SchemaBuilder } from "./builder";
import * as Types from "./types";
import { GQLiteralTypeWrapper } from "./definitions";
import { GQLiteralAbstract } from "./objects";
import { GQLiteralAbstract, GQLiteralDirectiveType } from "./objects";
/**
* Builds the types, normalizing the "types" passed into the schema for a
@ -11,7 +18,7 @@ import { GQLiteralAbstract } from "./objects";
export function buildTypes(
types: any,
config?: Pick<Types.SchemaConfig, "nullability" | "defaultResolver">
): Record<string, GraphQLNamedType> {
): Types.BuildTypes {
const builder = new SchemaBuilder(config || {});
addTypes(builder, types);
return builder.getFinalTypeMap();
@ -40,8 +47,13 @@ export function addMix(
}
function addTypes(builder: SchemaBuilder, types: any) {
if (!types) {
return;
}
if (types instanceof GQLiteralTypeWrapper || isNamedType(types)) {
builder.addType(types);
} else if (types instanceof GQLiteralDirectiveType || isDirective(types)) {
builder.addDirective(types);
} else if (Array.isArray(types)) {
types.forEach((typeDef) => addTypes(builder, typeDef));
} else if (isObject(types)) {
@ -90,6 +102,26 @@ export const propertyFieldResolver = (
}
};
/**
* If there are directives defined to be used on the types,
* we need to add these manually to the AST. Directives shouldn't
* be too common, since we're defining the schema programatically
* rather than by hand.
*/
export function addDirectives(
schema: string,
directives: Types.BuildTypesDirectives
) {
if (Object.keys(directives.uses).length > 0) {
return print(
visit(parse(schema), {
// TODO: Add directives
})
);
}
return schema;
}
// ----------------------------
/**

244
yarn.lock
View File

@ -16,44 +16,12 @@
esutils "^2.0.2"
js-tokens "^4.0.0"
"@graphql-modules/epoxy@0.1.9":
version "0.1.9"
resolved "https://registry.yarnpkg.com/@graphql-modules/epoxy/-/epoxy-0.1.9.tgz#291879d517ba4473ea334edbb137a2cc6aed384c"
dependencies:
"@graphql-modules/logger" "0.1.9"
"@types/deepmerge" "2.1.0"
deepmerge "2.2.1"
graphql-tools "4.0.2"
tslib "1.9.3"
"@graphql-modules/logger@0.1.9":
version "0.1.9"
resolved "https://registry.yarnpkg.com/@graphql-modules/logger/-/logger-0.1.9.tgz#768186df12ad488623ef7231d1bf096fe1610b76"
dependencies:
moment "2.22.2"
tslib "1.9.3"
winston "3.1.0"
"@samverschueren/stream-to-observable@^0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.0.tgz#ecdf48d532c58ea477acfcab80348424f8d0662f"
dependencies:
any-observable "^0.3.0"
"@types/babel-types@*":
version "7.0.4"
resolved "https://registry.yarnpkg.com/@types/babel-types/-/babel-types-7.0.4.tgz#bfd5b0d0d1ba13e351dff65b6e52783b816826c8"
"@types/babylon@6.16.3":
version "6.16.3"
resolved "https://registry.yarnpkg.com/@types/babylon/-/babylon-6.16.3.tgz#c2937813a89fcb5e79a00062fc4a8b143e7237bb"
dependencies:
"@types/babel-types" "*"
"@types/deepmerge@2.1.0":
version "2.1.0"
resolved "http://registry.npmjs.org/@types/deepmerge/-/deepmerge-2.1.0.tgz#22f175e5cb55874fe818caa6fd50a1d98fc3d748"
"@types/graphql@14.0.3":
version "14.0.3"
resolved "https://registry.yarnpkg.com/@types/graphql/-/graphql-14.0.3.tgz#389e2e5b83ecdb376d9f98fae2094297bc112c1c"
@ -62,10 +30,6 @@
version "4.0.39"
resolved "https://registry.yarnpkg.com/@types/handlebars/-/handlebars-4.0.39.tgz#961fb54db68030890942e6aeffe9f93a957807bd"
"@types/is-glob@4.0.0":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@types/is-glob/-/is-glob-4.0.0.tgz#fb8a2bff539025d4dcd6d5efe7689e03341b876d"
"@types/jest@^23.3.7":
version "23.3.7"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-23.3.7.tgz#77f9a4332ccf8db680a31818ade3ee454c831a79"
@ -74,14 +38,6 @@
version "10.12.2"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.2.tgz#d77f9faa027cadad9c912cd47f4f8b07b0fb0864"
"@types/prettier@1.13.2":
version "1.13.2"
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-1.13.2.tgz#ffe96278e712a8d4e467e367a338b05e22872646"
"@types/valid-url@1.0.2":
version "1.0.2"
resolved "http://registry.npmjs.org/@types/valid-url/-/valid-url-1.0.2.tgz#60fa435ce24bfd5ba107b8d2a80796aeaf3a8f45"
abab@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.0.tgz#aba0ab4c5eee2d4c79d3487d85450fb2376ebb0f"
@ -401,14 +357,6 @@ babel-traverse@^6.0.0, babel-traverse@^6.18.0, babel-traverse@^6.26.0:
invariant "^2.2.2"
lodash "^4.17.4"
babel-types@7.0.0-beta.3:
version "7.0.0-beta.3"
resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-7.0.0-beta.3.tgz#cd927ca70e0ae8ab05f4aab83778cfb3e6eb20b4"
dependencies:
esutils "^2.0.2"
lodash "^4.2.0"
to-fast-properties "^2.0.0"
babel-types@^6.0.0, babel-types@^6.18.0, babel-types@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497"
@ -418,10 +366,6 @@ babel-types@^6.0.0, babel-types@^6.18.0, babel-types@^6.26.0:
lodash "^4.17.4"
to-fast-properties "^1.0.3"
babylon@7.0.0-beta.47:
version "7.0.0-beta.47"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.47.tgz#6d1fa44f0abec41ab7c780481e62fd9aafbdea80"
babylon@^6.18.0:
version "6.18.0"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3"
@ -611,16 +555,6 @@ cli-cursor@^1.0.2:
dependencies:
restore-cursor "^1.0.1"
cli-cursor@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5"
dependencies:
restore-cursor "^2.0.0"
cli-spinners@^1.1.0:
version "1.3.1"
resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-1.3.1.tgz#002c1990912d0d59580c93bd36c056de99e4259a"
cli-truncate@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/cli-truncate/-/cli-truncate-0.2.1.tgz#9f15cfbb0705005369216c626ac7d05ab90dd574"
@ -636,10 +570,6 @@ cliui@^4.0.0:
strip-ansi "^4.0.0"
wrap-ansi "^2.0.0"
clone@^1.0.2:
version "1.0.4"
resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e"
co@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184"
@ -704,7 +634,7 @@ combined-stream@^1.0.6, combined-stream@~1.0.6:
dependencies:
delayed-stream "~1.0.0"
commander@2.19.0, commander@^2.12.1, commander@^2.14.1, commander@^2.9.0:
commander@^2.12.1, commander@^2.14.1, commander@^2.9.0:
version "2.19.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a"
@ -761,13 +691,6 @@ cosmiconfig@^5.0.2, cosmiconfig@^5.0.6:
js-yaml "^3.9.0"
parse-json "^4.0.0"
cross-fetch@2.2.2:
version "2.2.2"
resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-2.2.2.tgz#a47ff4f7fc712daba8f6a695a11c948440d45723"
dependencies:
node-fetch "2.1.2"
whatwg-fetch "2.0.4"
cross-spawn@^5.0.1:
version "5.1.0"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
@ -836,22 +759,12 @@ deep-is@~0.1.3:
version "0.1.3"
resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34"
deepmerge@2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-2.2.1.tgz#5d3ff22a01c00f645405a2fbc17d0778a1801170"
default-require-extensions@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/default-require-extensions/-/default-require-extensions-1.0.0.tgz#f37ea15d3e13ffd9b437d33e1a75b5fb97874cb8"
dependencies:
strip-bom "^2.0.0"
defaults@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d"
dependencies:
clone "^1.0.2"
define-properties@^1.1.2:
version "1.1.3"
resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1"
@ -1136,7 +1049,7 @@ fast-safe-stringify@^2.0.4:
version "2.0.6"
resolved "https://registry.yarnpkg.com/fast-safe-stringify/-/fast-safe-stringify-2.0.6.tgz#04b26106cc56681f51a044cfc0d76cf0008ac2c2"
fb-watchman@2.0.0, fb-watchman@^2.0.0:
fb-watchman@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/fb-watchman/-/fb-watchman-2.0.0.tgz#54e9abf7dfa2f26cd9b1636c588c1afc05de5d58"
dependencies:
@ -1307,7 +1220,7 @@ glob-parent@^2.0.0:
dependencies:
is-glob "^2.0.0"
glob@7.1.3, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2:
glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2:
version "7.1.3"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1"
dependencies:
@ -1326,34 +1239,6 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.2:
version "4.1.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
graphql-code-generator@^0.13.0:
version "0.13.0"
resolved "https://registry.yarnpkg.com/graphql-code-generator/-/graphql-code-generator-0.13.0.tgz#fd71fe9cd913f5ca14eedd7ce39c4e2ff6053ee1"
dependencies:
"@graphql-modules/epoxy" "0.1.9"
"@types/babylon" "6.16.3"
"@types/is-glob" "4.0.0"
"@types/prettier" "1.13.2"
"@types/valid-url" "1.0.2"
babel-types "7.0.0-beta.3"
babylon "7.0.0-beta.47"
chalk "2.4.1"
commander "2.19.0"
fb-watchman "2.0.0"
glob "7.1.3"
graphql-codegen-compiler "0.13.0"
graphql-codegen-core "0.13.0"
graphql-config "2.2.1"
graphql-import "0.7.1"
is-glob "4.0.0"
is-valid-path "0.1.1"
mkdirp "0.5.1"
ora "3.0.0"
pify "4.0.1"
prettier "1.14.3"
request "2.88.0"
valid-url "1.0.9"
graphql-codegen-compiler@0.13.0:
version "0.13.0"
resolved "https://registry.yarnpkg.com/graphql-codegen-compiler/-/graphql-codegen-compiler-0.13.0.tgz#5d7787849ce5b109f2ca7af681f428a1633c6b39"
@ -1377,47 +1262,10 @@ graphql-codegen-core@0.13.0:
ts-log "2.1.3"
winston "3.1.0"
graphql-codegen-typescript-template@^0.13.0:
version "0.13.0"
resolved "https://registry.yarnpkg.com/graphql-codegen-typescript-template/-/graphql-codegen-typescript-template-0.13.0.tgz#41398687cbf279f1d97d8cfb8aa7c412bf0e7192"
graphql-config@2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/graphql-config/-/graphql-config-2.2.1.tgz#5fd0ec77ac7428ca5fb2026cf131be10151a0cb2"
dependencies:
graphql-import "^0.7.1"
graphql-request "^1.5.0"
js-yaml "^3.10.0"
lodash "^4.17.4"
minimatch "^3.0.4"
graphql-import@0.7.1, graphql-import@^0.7.1:
version "0.7.1"
resolved "https://registry.yarnpkg.com/graphql-import/-/graphql-import-0.7.1.tgz#4add8d91a5f752d764b0a4a7a461fcd93136f223"
dependencies:
lodash "^4.17.4"
resolve-from "^4.0.0"
graphql-request@^1.5.0:
version "1.8.2"
resolved "https://registry.yarnpkg.com/graphql-request/-/graphql-request-1.8.2.tgz#398d10ae15c585676741bde3fc01d5ca948f8fbe"
dependencies:
cross-fetch "2.2.2"
graphql-tag@2.10.0:
version "2.10.0"
resolved "https://registry.yarnpkg.com/graphql-tag/-/graphql-tag-2.10.0.tgz#87da024be863e357551b2b8700e496ee2d4353ae"
graphql-tools@4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/graphql-tools/-/graphql-tools-4.0.2.tgz#9da22974cc6bf6524ed4f4af35556fd15aa6516d"
dependencies:
apollo-link "^1.2.3"
apollo-utilities "^1.0.1"
deprecated-decorator "^0.1.6"
iterall "^1.1.3"
uuid "^3.1.0"
graphql-tools@4.0.3:
version "4.0.3"
resolved "https://registry.yarnpkg.com/graphql-tools/-/graphql-tools-4.0.3.tgz#23b5cb52c519212b1b2e4630a361464396ad264b"
@ -1737,23 +1585,17 @@ is-generator-fn@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-generator-fn/-/is-generator-fn-1.0.0.tgz#969d49e1bb3329f6bb7f09089be26578b2ddd46a"
is-glob@4.0.0, is-glob@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.0.tgz#9521c76845cc2610a85203ddf080a958c2ffabc0"
dependencies:
is-extglob "^2.1.1"
is-glob@^2.0.0, is-glob@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-2.0.1.tgz#d096f926a3ded5600f3fdfd91198cb0888c2d863"
dependencies:
is-extglob "^1.0.0"
is-invalid-path@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/is-invalid-path/-/is-invalid-path-0.1.0.tgz#307a855b3cf1a938b44ea70d2c61106053714f34"
is-glob@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.0.tgz#9521c76845cc2610a85203ddf080a958c2ffabc0"
dependencies:
is-glob "^2.0.0"
is-extglob "^2.1.1"
is-lower-case@^1.1.0:
version "1.1.3"
@ -1839,12 +1681,6 @@ is-utf8@^0.2.0:
version "0.2.1"
resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72"
is-valid-path@0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/is-valid-path/-/is-valid-path-0.1.1.tgz#110f9ff74c37f663e1ec7915eb451f2db93ac9df"
dependencies:
is-invalid-path "^0.1.0"
is-windows@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d"
@ -2236,7 +2072,7 @@ js-tokens@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
js-yaml@^3.10.0, js-yaml@^3.7.0, js-yaml@^3.9.0:
js-yaml@^3.7.0, js-yaml@^3.9.0:
version "3.12.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.0.tgz#eaed656ec8344f10f527c6bfa1b6e2244de167d1"
dependencies:
@ -2463,7 +2299,7 @@ lodash.sortby@^4.7.0:
version "4.7.0"
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.0:
lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.4, lodash@^4.17.5:
version "4.17.11"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
@ -2647,7 +2483,7 @@ mixin-deep@^1.2.0:
for-in "^1.0.2"
is-extendable "^1.0.1"
mkdirp@0.5.1, mkdirp@0.x, mkdirp@^0.5.0, mkdirp@^0.5.1:
mkdirp@0.x, mkdirp@^0.5.0, mkdirp@^0.5.1:
version "0.5.1"
resolved "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903"
dependencies:
@ -2703,10 +2539,6 @@ no-case@^2.2.0, no-case@^2.3.2:
dependencies:
lower-case "^1.1.1"
node-fetch@2.1.2:
version "2.1.2"
resolved "http://registry.npmjs.org/node-fetch/-/node-fetch-2.1.2.tgz#ab884e8e7e57e38a944753cec706f788d1768bb5"
node-int64@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"
@ -2865,12 +2697,6 @@ onetime@^1.0.0:
version "1.1.0"
resolved "http://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz#a1f7838f8314c516f05ecefcbc4ccfe04b4ed789"
onetime@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4"
dependencies:
mimic-fn "^1.0.0"
optimist@^0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686"
@ -2889,17 +2715,6 @@ optionator@^0.8.1:
type-check "~0.3.2"
wordwrap "~1.0.0"
ora@3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/ora/-/ora-3.0.0.tgz#8179e3525b9aafd99242d63cc206fd64732741d0"
dependencies:
chalk "^2.3.1"
cli-cursor "^2.1.0"
cli-spinners "^1.1.0"
log-symbols "^2.2.0"
strip-ansi "^4.0.0"
wcwidth "^1.0.1"
os-homedir@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3"
@ -3050,10 +2865,6 @@ performance-now@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
pify@4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/pify/-/pify-4.0.1.tgz#4b2cd25c50d598735c50292224fd8c6df41e3231"
pify@^2.0.0:
version "2.3.0"
resolved "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
@ -3106,7 +2917,7 @@ preserve@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
prettier@1.14.3, prettier@^1.14.3:
prettier@^1.14.3:
version "1.14.3"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.14.3.tgz#90238dd4c0684b7edce5f83b0fb7328e48bd0895"
@ -3259,7 +3070,7 @@ request-promise-native@^1.0.5:
stealthy-require "^1.1.0"
tough-cookie ">=2.3.3"
request@2.88.0, request@^2.87.0:
request@^2.87.0:
version "2.88.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.88.0.tgz#9c2fca4f7d35b592efe57c7f0a55e81052124fef"
dependencies:
@ -3302,10 +3113,6 @@ resolve-from@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-3.0.0.tgz#b22c7af7d9d6881bc8b6e653335eebcb0a188748"
resolve-from@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6"
resolve-url@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
@ -3327,13 +3134,6 @@ restore-cursor@^1.0.1:
exit-hook "^1.0.0"
onetime "^1.0.0"
restore-cursor@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf"
dependencies:
onetime "^2.0.0"
signal-exit "^3.0.2"
ret@~0.1.10:
version "0.1.15"
resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc"
@ -3751,10 +3551,6 @@ to-fast-properties@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47"
to-fast-properties@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e"
to-object-path@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af"
@ -3815,7 +3611,7 @@ ts-log@2.1.3:
version "2.1.3"
resolved "https://registry.yarnpkg.com/ts-log/-/ts-log-2.1.3.tgz#9e30aca1baffe7693a2e4142b8f07ecb01cb8340"
tslib@1.9.3, tslib@^1.8.0, tslib@^1.8.1, tslib@^1.9.0:
tslib@^1.8.0, tslib@^1.8.1, tslib@^1.9.0:
version "1.9.3"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
@ -3918,10 +3714,6 @@ uuid@^3.1.0, uuid@^3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131"
valid-url@1.0.9:
version "1.0.9"
resolved "https://registry.yarnpkg.com/valid-url/-/valid-url-1.0.9.tgz#1c14479b40f1397a75782f115e4086447433a200"
validate-npm-package-license@^3.0.1:
version "3.0.4"
resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a"
@ -3956,12 +3748,6 @@ watch@~0.18.0:
exec-sh "^0.2.0"
minimist "^1.2.0"
wcwidth@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8"
dependencies:
defaults "^1.0.3"
webidl-conversions@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad"
@ -3972,10 +3758,6 @@ whatwg-encoding@^1.0.1, whatwg-encoding@^1.0.3:
dependencies:
iconv-lite "0.4.24"
whatwg-fetch@2.0.4:
version "2.0.4"
resolved "http://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz#dde6a5df315f9d39991aa17621853d720b85566f"
whatwg-mimetype@^2.1.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/whatwg-mimetype/-/whatwg-mimetype-2.2.0.tgz#a3d58ef10b76009b042d03e25591ece89b88d171"