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

nexus

Package Overview
Dependencies
Maintainers
3
Versions
395
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nexus - npm Package Compare versions

Comparing version 0.9.15 to 0.9.16

dist/definitions/extendInputType.d.ts

5

CHANGELOG.md
# Changelog
### 0.9.16
- Fix #52, args being incorrectly imported as types
- Feature: extendInputType, #51
### 0.9.15

@@ -4,0 +9,0 @@

@@ -53,2 +53,6 @@ import {

import { GetGen } from "./typegenTypeHelpers";
import {
NexusExtendInputTypeDef,
NexusExtendInputTypeConfig,
} from "./definitions/extendInputType";
export declare type Maybe<T> = T | null;

@@ -170,2 +174,9 @@ export interface BuilderConfig {

/**
* All "extensions" to input types (adding fields on types from many locations)
*/
protected inputTypeExtensionMap: Record<
string,
NexusExtendInputTypeConfig<string>[] | null
>;
/**
* Configures the root-level nonNullDefaults defaults

@@ -184,2 +195,3 @@ */

| AllNexusNamedTypeDefs
| NexusExtendInputTypeDef<string>
| NexusExtendTypeDef<string>

@@ -186,0 +198,0 @@ | GraphQLNamedType

@@ -51,2 +51,6 @@ "use strict";

/**
* All "extensions" to input types (adding fields on types from many locations)
*/
this.inputTypeExtensionMap = {};
/**
* Configures the root-level nonNullDefaults defaults

@@ -73,2 +77,8 @@ */

}
if (wrapping_1.isNexusExtendInputTypeDef(typeDef)) {
var typeExtensions = (this.inputTypeExtensionMap[typeDef.name] =
this.inputTypeExtensionMap[typeDef.name] || []);
typeExtensions.push(typeDef.value);
return;
}
if (existingType) {

@@ -131,2 +141,11 @@ // Allow importing the same exact type more than once.

});
Object.keys(this.inputTypeExtensionMap).forEach(function (key) {
// If we haven't defined the type, assume it's an object type
if (_this.inputTypeExtensionMap[key] !== null) {
_this.buildInputObjectType({
name: key,
definition: function () { },
});
}
});
return {

@@ -143,2 +162,9 @@ typeMap: this.finalTypeMap,

config.definition(this.withScalarMethods(definitionBlock));
var extensions = this.inputTypeExtensionMap[config.name];
if (extensions) {
extensions.forEach(function (extension) {
extension.definition(definitionBlock);
});
}
this.inputTypeExtensionMap[config.name] = null;
return this.finalize(new graphql_1.GraphQLInputObjectType({

@@ -582,2 +608,3 @@ name: config.name,

wrapping_1.isNexusExtendTypeDef(types) ||
wrapping_1.isNexusExtendInputTypeDef(types) ||
graphql_1.isNamedType(types)) {

@@ -584,0 +611,0 @@ builder.addType(types);

1

dist/core.d.ts

@@ -14,2 +14,3 @@ export * from "./builder";

export * from "./definitions/extendType";
export * from "./definitions/extendInputType";
export * from "./definitions/inputObjectType";

@@ -16,0 +17,0 @@ export * from "./definitions/interfaceType";

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

tslib_1.__exportStar(require("./definitions/extendType"), exports);
tslib_1.__exportStar(require("./definitions/extendInputType"), exports);
tslib_1.__exportStar(require("./definitions/inputObjectType"), exports);

@@ -20,0 +21,0 @@ tslib_1.__exportStar(require("./definitions/interfaceType"), exports);

@@ -17,2 +17,3 @@ import {

ExtendObject = "ExtendObject",
ExtendInputObject = "ExtendInputObject",
WrappedType = "WrappedType",

@@ -19,0 +20,0 @@ OutputField = "OutputField",

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

NexusTypes["ExtendObject"] = "ExtendObject";
NexusTypes["ExtendInputObject"] = "ExtendInputObject";
NexusTypes["WrappedType"] = "WrappedType";

@@ -15,0 +16,0 @@ NexusTypes["OutputField"] = "OutputField";

2

dist/definitions/args.js

@@ -20,3 +20,3 @@ "use strict";

exports.NexusArgDef = NexusArgDef;
_types_1.withNexusSymbol(NexusArgDef, _types_1.NexusTypes.Interface);
_types_1.withNexusSymbol(NexusArgDef, _types_1.NexusTypes.Arg);
/**

@@ -23,0 +23,0 @@ * Defines an argument that can be used in any object or interface type

import { OutputDefinitionBlock } from "./definitionBlocks";
import { GetGen } from "../typegenTypeHelpers";
export interface NexusExtendTypeConfig<TypeName extends string> {

@@ -18,4 +19,4 @@ type: TypeName;

*/
export declare function extendType<TypeName extends string>(
config: NexusExtendTypeConfig<TypeName>
): NexusExtendTypeDef<TypeName>;
export declare function extendType<
TypeName extends GetGen<"objectNames", string> | "Query" | "Mutation"
>(config: NexusExtendTypeConfig<TypeName>): NexusExtendTypeDef<TypeName>;

@@ -11,2 +11,3 @@ import { GraphQLNamedType } from "graphql";

import { NexusTypes, NexusWrappedSymbol } from "./_types";
import { NexusExtendInputTypeDef } from "./extendInputType";
export declare type NexusInputTypeName<T> = T extends NexusInputObjectTypeDef<

@@ -68,2 +69,5 @@ infer A

): obj is AllNexusNamedTypeDefs;
export declare function isNexusExtendInputTypeDef(
obj: any
): obj is NexusExtendInputTypeDef<string>;
export declare function isNexusExtendTypeDef(

@@ -70,0 +74,0 @@ obj: any

@@ -49,2 +49,7 @@ "use strict";

exports.isNexusNamedTypeDef = isNexusNamedTypeDef;
function isNexusExtendInputTypeDef(obj) {
return (isNexusTypeDef(obj) &&
obj[_types_1.NexusWrappedSymbol] === _types_1.NexusTypes.ExtendInputObject);
}
exports.isNexusExtendInputTypeDef = isNexusExtendInputTypeDef;
function isNexusExtendTypeDef(obj) {

@@ -51,0 +56,0 @@ return (isNexusTypeDef(obj) && obj[_types_1.NexusWrappedSymbol] === _types_1.NexusTypes.ExtendObject);

@@ -12,2 +12,3 @@ export { buildTypes, makeSchema } from "./builder";

export { extendType } from "./definitions/extendType";
export { extendInputType } from "./definitions/extendInputType";
export { inputObjectType } from "./definitions/inputObjectType";

@@ -14,0 +15,0 @@ export { interfaceType } from "./definitions/interfaceType";

@@ -19,2 +19,4 @@ "use strict";

exports.extendType = extendType_1.extendType;
var extendInputType_1 = require("./definitions/extendInputType");
exports.extendInputType = extendInputType_1.extendInputType;
var inputObjectType_1 = require("./definitions/inputObjectType");

@@ -21,0 +23,0 @@ exports.inputObjectType = inputObjectType_1.inputObjectType;

@@ -392,3 +392,5 @@ "use strict";

}
else if (graphql_1.isObjectType(type) || graphql_1.isInterfaceType(type) || graphql_1.isUnionType(type)) {
else if (graphql_1.isObjectType(type) ||
graphql_1.isInterfaceType(type) ||
graphql_1.isUnionType(type)) {
typing.push("NexusGenRootTypes['" + type.name + "']");

@@ -395,0 +397,0 @@ }

{
"name": "nexus",
"version": "0.9.15",
"version": "0.9.16",
"main": "dist",

@@ -17,3 +17,3 @@ "types": "dist",

"prepublish": "yarn clean && yarn lint && yarn build",
"postpublish": "yarn upgrade-deps",
"postpublish": "yarn upgrade-deps || echo 'Oops...'",
"website": "cd website && yarn && yarn start",

@@ -20,0 +20,0 @@ "examples": "yarn link-examples && cd website && yarn gulp run-examples",

@@ -14,3 +14,3 @@ <p align="center"><a href="https://nexus.js.org"><img src="https://i.imgur.com/Y5BgDGl.png" width="150" /><a></p>

- **Type-safe**: Nexus enables auto-completion and error checks in your IDE (even for JS)
- **Generates SDL & TS definitions**: SDL schema and typings are updated as you code
- **Generates SDL & TS definitions**: SDL schema and typings are updated as you code

@@ -36,2 +36,6 @@ ## Features

## CI
[![CircleCI](https://circleci.com/gh/prisma/nexus.svg?style=svg)](https://circleci.com/gh/prisma/nexus)
## Install

@@ -65,13 +69,13 @@

```ts
import { queryType, stringArg, makeSchema } from 'nexus'
import { GraphQLServer } from 'graphql-yoga'
import { queryType, stringArg, makeSchema } from "nexus";
import { GraphQLServer } from "graphql-yoga";
const Query = queryType({
definition(t) {
t.string('hello', {
t.string("hello", {
args: { name: stringArg({ nullable: true }) },
resolve: (parent, { name }) => `Hello ${name || 'World'}!`,
})
resolve: (parent, { name }) => `Hello ${name || "World"}!`,
});
},
})
});

@@ -81,12 +85,12 @@ const schema = makeSchema({

outputs: {
schema: __dirname + '/generated/schema.graphql',
typegen: __dirname + '/generated/typings.ts',
schema: __dirname + "/generated/schema.graphql",
typegen: __dirname + "/generated/typings.ts",
},
})
});
const server = new GraphQLServer({
schema,
})
});
server.start(() => `Server is running on http://localhost:4000`)
server.start(() => `Server is running on http://localhost:4000`);
```

@@ -96,3 +100,2 @@

<Details>

@@ -99,0 +102,0 @@ <Summary>Example: Star Wars</Summary>

@@ -79,2 +79,3 @@ import {

NexusWrappedType,
isNexusExtendInputTypeDef,
} from "./definitions/wrapping";

@@ -91,2 +92,6 @@ import {

import { firstDefined, objValues, suggestionList, isObject } from "./utils";
import {
NexusExtendInputTypeDef,
NexusExtendInputTypeConfig,
} from "./definitions/extendInputType";

@@ -220,2 +225,9 @@ export type Maybe<T> = T | null;

/**
* All "extensions" to input types (adding fields on types from many locations)
*/
protected inputTypeExtensionMap: Record<
string,
NexusExtendInputTypeConfig<string>[] | null
> = {};
/**
* Configures the root-level nonNullDefaults defaults

@@ -246,2 +258,3 @@ */

| AllNexusNamedTypeDefs
| NexusExtendInputTypeDef<string>
| NexusExtendTypeDef<string>

@@ -260,2 +273,9 @@ | GraphQLNamedType

if (isNexusExtendInputTypeDef(typeDef)) {
const typeExtensions = (this.inputTypeExtensionMap[typeDef.name] =
this.inputTypeExtensionMap[typeDef.name] || []);
typeExtensions.push(typeDef.value);
return;
}
if (existingType) {

@@ -320,2 +340,11 @@ // Allow importing the same exact type more than once.

});
Object.keys(this.inputTypeExtensionMap).forEach((key) => {
// If we haven't defined the type, assume it's an object type
if (this.inputTypeExtensionMap[key] !== null) {
this.buildInputObjectType({
name: key,
definition() {},
});
}
});
return {

@@ -334,2 +363,9 @@ typeMap: this.finalTypeMap,

config.definition(this.withScalarMethods(definitionBlock));
const extensions = this.inputTypeExtensionMap[config.name];
if (extensions) {
extensions.forEach((extension) => {
extension.definition(definitionBlock);
});
}
this.inputTypeExtensionMap[config.name] = null;
return this.finalize(

@@ -516,5 +552,5 @@ new GraphQLInputObjectType({

protected withScalarMethods<T extends NexusGenCustomDefinitionMethods<string>>(
definitionBlock: T
): T {
protected withScalarMethods<
T extends NexusGenCustomDefinitionMethods<string>
>(definitionBlock: T): T {
this.customScalarMethods.forEach(([methodName, typeName]) => {

@@ -954,2 +990,3 @@ // @ts-ignore - Yeah, yeah... we know

isNexusExtendTypeDef(types) ||
isNexusExtendInputTypeDef(types) ||
isNamedType(types)

@@ -956,0 +993,0 @@ ) {

@@ -16,2 +16,3 @@ // The "core" is used as a namespace to re-export everything,

export * from "./definitions/extendType";
export * from "./definitions/extendInputType";
export * from "./definitions/inputObjectType";

@@ -18,0 +19,0 @@ export * from "./definitions/interfaceType";

@@ -20,2 +20,3 @@ import {

ExtendObject = "ExtendObject",
ExtendInputObject = "ExtendInputObject",
WrappedType = "WrappedType",

@@ -22,0 +23,0 @@ OutputField = "OutputField",

@@ -59,3 +59,3 @@ import { GetGen, GetGen2 } from "../typegenTypeHelpers";

withNexusSymbol(NexusArgDef, NexusTypes.Interface);
withNexusSymbol(NexusArgDef, NexusTypes.Arg);

@@ -62,0 +62,0 @@ /**

import { NexusTypes, withNexusSymbol } from "./_types";
import { OutputDefinitionBlock } from "./definitionBlocks";
import { assertValidName } from "graphql";
import { GetGen } from "../typegenTypeHelpers";

@@ -30,6 +31,6 @@ export interface NexusExtendTypeConfig<TypeName extends string> {

*/
export function extendType<TypeName extends string>(
config: NexusExtendTypeConfig<TypeName>
) {
export function extendType<
TypeName extends GetGen<"objectNames", string> | "Query" | "Mutation"
>(config: NexusExtendTypeConfig<TypeName>) {
return new NexusExtendTypeDef(config.type, config);
}

@@ -11,2 +11,3 @@ import { GraphQLNamedType } from "graphql";

import { NexusTypes, NexusWrappedSymbol, withNexusSymbol } from "./_types";
import { NexusExtendInputTypeDef } from "./extendInputType";

@@ -88,2 +89,10 @@ export type NexusInputTypeName<T> = T extends NexusInputObjectTypeDef<infer A>

}
export function isNexusExtendInputTypeDef(
obj: any
): obj is NexusExtendInputTypeDef<string> {
return (
isNexusTypeDef(obj) &&
obj[NexusWrappedSymbol] === NexusTypes.ExtendInputObject
);
}
export function isNexusExtendTypeDef(

@@ -90,0 +99,0 @@ obj: any

@@ -13,2 +13,3 @@ // All of the Public API definitions

export { extendType } from "./definitions/extendType";
export { extendInputType } from "./definitions/extendInputType";
export { inputObjectType } from "./definitions/inputObjectType";

@@ -15,0 +16,0 @@ export { interfaceType } from "./definitions/interfaceType";

@@ -453,3 +453,7 @@ import {

typing.push(`NexusGenEnums['${type.name}']`);
} else if (isObjectType(type) || isInterfaceType(type) || isUnionType(type)) {
} else if (
isObjectType(type) ||
isInterfaceType(type) ||
isUnionType(type)
) {
typing.push(`NexusGenRootTypes['${type.name}']`);

@@ -456,0 +460,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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