@pothos/plugin-with-input
Advanced tools
Comparing version 3.4.0 to 3.5.0
# @pothos/plugin-with-input | ||
## 3.5.0 | ||
### Minor Changes | ||
- ecb2714c: Add types entry to export map in package.json and update dev dependencies | ||
This should fix compatibility with typescripts new `"moduleResolution": "node12"` | ||
## 3.4.0 | ||
@@ -4,0 +12,0 @@ |
@@ -24,22 +24,40 @@ "use strict"; | ||
}); | ||
function _getRequireWildcardCache() { | ||
if (typeof WeakMap !== "function") return null; | ||
var cache = new WeakMap(); | ||
_getRequireWildcardCache = function() { | ||
return cache; | ||
}; | ||
return cache; | ||
} | ||
function _interopRequireWildcard(obj) { | ||
if (obj && obj.__esModule) { | ||
return obj; | ||
} else { | ||
var newObj = {}; | ||
if (obj != null) { | ||
for(var key in obj){ | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; | ||
if (desc.get || desc.set) { | ||
Object.defineProperty(newObj, key, desc); | ||
} else { | ||
newObj[key] = obj[key]; | ||
} | ||
} | ||
} | ||
if (obj === null || typeof obj !== "object" && typeof obj !== "function") { | ||
return { | ||
default: obj | ||
}; | ||
} | ||
var cache = _getRequireWildcardCache(); | ||
if (cache && cache.has(obj)) { | ||
return cache.get(obj); | ||
} | ||
var newObj = {}; | ||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; | ||
for(var key in obj){ | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; | ||
if (desc && (desc.get || desc.set)) { | ||
Object.defineProperty(newObj, key, desc); | ||
} else { | ||
newObj[key] = obj[key]; | ||
} | ||
} | ||
newObj.default = obj; | ||
return newObj; | ||
} | ||
newObj.default = obj; | ||
if (cache) { | ||
cache.set(obj, newObj); | ||
} | ||
return newObj; | ||
} | ||
@@ -46,0 +64,0 @@ const pluginName = 'withInput'; |
{ | ||
"name": "@pothos/plugin-with-input", | ||
"version": "3.4.0", | ||
"version": "3.5.0", | ||
"description": "A Pothos plugin for defining fields with input objects", | ||
@@ -9,2 +9,3 @@ "main": "./lib/index.js", | ||
"exports": { | ||
"types": "./dts/index.d.ts", | ||
"import": "./esm/index.js", | ||
@@ -35,5 +36,6 @@ "require": "./lib/index.js" | ||
"devDependencies": { | ||
"@pothos/core": "3.8.0", | ||
"@pothos/plugin-validation": "3.3.0", | ||
"@pothos/test-utils": "1.1.1", | ||
"@pothos/core": "3.11.0", | ||
"@pothos/plugin-validation": "3.4.0", | ||
"@pothos/test-utils": "1.2.0", | ||
"graphql": "16.5.0", | ||
"graphql-tag": "^2.12.6" | ||
@@ -50,4 +52,3 @@ }, | ||
"test": "pnpm jest --runInBand" | ||
}, | ||
"readme": "# With-Input Plugin\n\nA plugin for creating fields with a single input object. This plugin adds a new `t.fieldWithInput`\nmethod that allows you to more easily define fields with a single input type without having to\ndefine it separately.\n\n## Usage\n\n### Install\n\n```bash\nyarn add @pothos/plugin-with-input\n```\n\n### Setup\n\n```typescript\nimport WithInputPlugin from '@pothos/plugin-with-input';\nconst builder = new SchemaBuilder({\n plugins: [WithInputPlugin],\n // optional\n withInput: {\n typeOptions: {\n // default options for Input object types created by this plugin\n },\n argOptions: {\n // set required: false to override default behavior\n },\n },\n});\n```\n\n### Defining fields with inputs\n\n```typescript\nbuilder.queryType({\n fields: (t) => ({\n example: t.fieldWithInput({\n input: {\n // Note that this uses a new t.input field builder for defining input fields\n id: t.input.id({ required: true }),\n },\n type: 'ID',\n resolve: (root, args) => args.input.id,\n }),\n }),\n});\n```\n\nThis will produce a schema like:\n\n```graphql\ntype Query {\n example(input: QueryExampleInput!): ID!\n}\n\ninput QueryExampleInput {\n id: ID!\n}\n```\n\nThe input name will default to `${ParentType.name}${Field.name}Input`.\n\n### Customizing your input object\n\nYou can customize the name of your Input object, and the name of the input argument:\n\n```typescript\nbuilder.queryType({\n fields: (t) => ({\n example: t.fieldWithInput({\n typeOptions: {\n name: 'CustomInputTypeName',\n // Additional options for the input type can be added here\n },\n argOptions: {\n name: 'customArgName',\n // Additional options for the input argument can be added here\n },\n input: {\n id: t.input.id({ required: true }),\n },\n type: 'ID',\n // inputs are now under `customArgName`\n resolve: (root, args) => args.customArgName.id,\n }),\n }),\n});\n```\n\n### Changing the nullability of the input arg\n\nYou can configure the global default for input args when creating the builder by providing\n`WithInputArgRequired` in the builders `SchemaTypes`, and setting `withInput.argOptions.required`.\n\n```typescript\nconst builder = new SchemaBuilder<{ WithInputArgRequired: false }>({\n plugins: [WithInputPlugin],\n withInput: {\n argOptions: {\n required: false,\n },\n },\n});\n```\n\narg requiredness can also be set on a per field basis by setting `argOptions.required`\n\n```typescript\nbuilder.queryType({\n fields: (t) => ({\n example: t.fieldWithInput({\n type: 'Boolean',\n nulllable: true,\n argOptions: {\n required: false,\n },\n input: {\n someInput: t.input.boolean({}),\n },\n resolve: (root, args) => {\n return args.input?.someInput;\n },\n }),\n});\n```\n" | ||
} | ||
} |
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
Sorry, the diff of this file is not supported yet
449
88221
5