nexus-prisma
Advanced tools
Comparing version 0.5.0-next.4 to 0.5.0-next.5
@@ -64,6 +64,6 @@ "use strict"; | ||
else if (process.env.NEXUS_PRISMA_LINK) { | ||
defaultTypegenPath = path.join(process.cwd(), 'node_modules/@types/__nexus-typegen__nexus-prisma/index.d.ts'); | ||
defaultTypegenPath = path.join(process.cwd(), 'node_modules/@types/nexus-prisma-typegen/index.d.ts'); | ||
} | ||
else { | ||
defaultTypegenPath = path.join(__dirname, '../../@types/__nexus-typegen__nexus-prisma/index.d.ts'); | ||
defaultTypegenPath = path.join(__dirname, '../../@types/nexus-prisma-typegen/index.d.ts'); | ||
} | ||
@@ -70,0 +70,0 @@ // Note Default should be updated once resolved: |
@@ -12,4 +12,4 @@ import * as DMMF from './dmmf'; | ||
} | ||
export declare const getCrudMappedFields: (typeName: "Query" | "Mutation", dmmf: DMMF.DMMF, namingStrategy?: Record<"findOne" | "findMany" | "create" | "update" | "updateMany" | "upsert" | "delete" | "deleteMany", (fieldName: string, modelName: string) => string>) => MappedField[]; | ||
export declare const getCrudMappedFields: (typeName: "Query" | "Mutation", dmmf: DMMF.DMMF, namingStrategy?: Record<"delete" | "findOne" | "findMany" | "create" | "update" | "updateMany" | "upsert" | "deleteMany", (fieldName: string, modelName: string) => string>) => MappedField[]; | ||
export {}; | ||
//# sourceMappingURL=mapping.d.ts.map |
@@ -10,7 +10,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const fs = __importStar(require("fs-extra")); | ||
const path = __importStar(require("path")); | ||
const DMMF = __importStar(require("./dmmf")); | ||
const mapping_1 = require("./mapping"); | ||
const naming_strategies_1 = require("./naming-strategies"); | ||
const utils_1 = require("./utils"); | ||
function generateSync(options) { | ||
@@ -28,9 +27,6 @@ doGenerate(true, options); | ||
if (sync) { | ||
fs.mkdirpSync(path.dirname(options.typegenPath)); | ||
fs.writeFileSync(options.typegenPath, tsDeclaration); | ||
utils_1.hardWriteFileSync(options.typegenPath, tsDeclaration); | ||
} | ||
else { | ||
return fs | ||
.mkdirp(path.dirname(options.typegenPath)) | ||
.then(() => fs.writeFile(options.typegenPath, tsDeclaration)); | ||
return utils_1.hardWriteFile(options.typegenPath, tsDeclaration); | ||
} | ||
@@ -37,0 +33,0 @@ } |
/** | ||
* Write file contents but first delete the file off disk if present. This is a | ||
* useful function when the effect of file delete is needed to trigger some file | ||
* watch/refresh mechanism, such as is the case with VSCode TS declaration files | ||
* inside `@types/` packages. | ||
* | ||
* For more details that motivated this utility refer to the originating issue | ||
* https://github.com/prisma-labs/nexus-prisma/issues/453. | ||
*/ | ||
export declare const hardWriteFile: (filePath: string, data: string) => Promise<void>; | ||
/** | ||
* Write file contents but first delete the file off disk if present. This is a | ||
* useful function when the effect of file delete is needed to trigger some file | ||
* watch/refresh mechanism, such as is the case with VSCode TS declaration files | ||
* inside `@types/` packages. | ||
* | ||
* For more details that motivated this utility refer to the originating issue | ||
* https://github.com/prisma-labs/nexus-prisma/issues/453. | ||
*/ | ||
export declare const hardWriteFileSync: (filePath: string, data: string) => void; | ||
/** | ||
* TODO | ||
@@ -3,0 +23,0 @@ */ |
"use strict"; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -6,2 +13,40 @@ const graphql_1 = require("graphql"); | ||
const path_1 = require("path"); | ||
const fs = __importStar(require("fs-extra")); | ||
const path = __importStar(require("path")); | ||
/** | ||
* Write file contents but first delete the file off disk if present. This is a | ||
* useful function when the effect of file delete is needed to trigger some file | ||
* watch/refresh mechanism, such as is the case with VSCode TS declaration files | ||
* inside `@types/` packages. | ||
* | ||
* For more details that motivated this utility refer to the originating issue | ||
* https://github.com/prisma-labs/nexus-prisma/issues/453. | ||
*/ | ||
exports.hardWriteFile = (filePath, data) => fs | ||
.unlink(filePath) | ||
.catch(error => { | ||
return error.code === 'ENOENT' ? Promise.resolve() : Promise.reject(error); | ||
}) | ||
.then(() => fs.mkdirp(path.dirname(filePath))) | ||
.then(() => fs.writeFile(filePath, data)); | ||
/** | ||
* Write file contents but first delete the file off disk if present. This is a | ||
* useful function when the effect of file delete is needed to trigger some file | ||
* watch/refresh mechanism, such as is the case with VSCode TS declaration files | ||
* inside `@types/` packages. | ||
* | ||
* For more details that motivated this utility refer to the originating issue | ||
* https://github.com/prisma-labs/nexus-prisma/issues/453. | ||
*/ | ||
exports.hardWriteFileSync = (filePath, data) => { | ||
fs.mkdirpSync(path.dirname(filePath)); | ||
try { | ||
fs.unlinkSync(filePath); | ||
} | ||
catch (error) { | ||
if (error.code !== 'ENOENT') | ||
throw error; | ||
} | ||
fs.writeFileSync(filePath, data); | ||
}; | ||
// TODO `any` should be `unknown` but there is a bug (?) | ||
@@ -8,0 +53,0 @@ // preventing that from working, see: |
{ | ||
"name": "nexus-prisma", | ||
"version": "0.5.0-next.4", | ||
"version": "0.5.0-next.5", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
@@ -1,6 +0,8 @@ | ||
<p align="center"><img src="https://i.imgur.com/8qvElTM.png" width="300" /></p> | ||
<p><h1 align="center">nexus-prisma</h1></p> | ||
<a href="https://circleci.com/gh/prisma-labs/nexus-prisma"><img src="https://circleci.com/gh/prisma-labs/nexus-prisma.svg?style=svg"></img></a> | ||
<p align="center"> | ||
<img src="https://i.imgur.com/8qvElTM.png" width="300" align="center" /> | ||
<h1 align="center">nexus-prisma</h1> | ||
</p> | ||
[![CircleCI](https://circleci.com/gh/prisma-labs/nexus-prisma.svg?style=svg)](https://circleci.com/gh/prisma-labs/nexus-prisma) | ||
`nexus-prisma` is a plugin for bridging [Prisma](https://www.prisma.io) and [Nexus](https://nexus.js.org). It extends the Nexus DSL `t` with `.model` and `.crud` making it easy to expose Prisma models and operations against them in your GraphQL API. The resolvers for these operations (pagination, filtering, ordering, and more), are dynamically created for you removing the need for traditional ORMs/query builders like TypeORM, Sequelize, or knex. And when you do need to drop down into custom resolvers a [Photon](https://photonjs.prisma.io) instance on `ctx` will be ready to serve you, the same great tool `nexus-prisma` itself bulids upon. | ||
@@ -7,0 +9,0 @@ |
@@ -90,3 +90,3 @@ import * as Nexus from 'nexus' | ||
process.cwd(), | ||
'node_modules/@types/__nexus-typegen__nexus-prisma/index.d.ts', | ||
'node_modules/@types/nexus-prisma-typegen/index.d.ts', | ||
) | ||
@@ -96,3 +96,3 @@ } else { | ||
__dirname, | ||
'../../@types/__nexus-typegen__nexus-prisma/index.d.ts', | ||
'../../@types/nexus-prisma-typegen/index.d.ts', | ||
) | ||
@@ -99,0 +99,0 @@ } |
@@ -1,6 +0,5 @@ | ||
import * as fs from 'fs-extra' | ||
import * as path from 'path' | ||
import * as DMMF from './dmmf' | ||
import { getCrudMappedFields } from './mapping' | ||
import { defaultFieldNamingStrategy } from './naming-strategies' | ||
import { hardWriteFileSync, hardWriteFile } from './utils' | ||
@@ -29,8 +28,5 @@ type Options = { | ||
if (sync) { | ||
fs.mkdirpSync(path.dirname(options.typegenPath)) | ||
fs.writeFileSync(options.typegenPath, tsDeclaration) | ||
hardWriteFileSync(options.typegenPath, tsDeclaration) | ||
} else { | ||
return fs | ||
.mkdirp(path.dirname(options.typegenPath)) | ||
.then(() => fs.writeFile(options.typegenPath, tsDeclaration)) | ||
return hardWriteFile(options.typegenPath, tsDeclaration) | ||
} | ||
@@ -37,0 +33,0 @@ } |
import { isNamedType } from 'graphql' | ||
import { core } from 'nexus' | ||
import { relative } from 'path' | ||
import * as fs from 'fs-extra' | ||
import * as path from 'path' | ||
import { thisExpression } from '@babel/types' | ||
/** | ||
* Write file contents but first delete the file off disk if present. This is a | ||
* useful function when the effect of file delete is needed to trigger some file | ||
* watch/refresh mechanism, such as is the case with VSCode TS declaration files | ||
* inside `@types/` packages. | ||
* | ||
* For more details that motivated this utility refer to the originating issue | ||
* https://github.com/prisma-labs/nexus-prisma/issues/453. | ||
*/ | ||
export const hardWriteFile = (filePath: string, data: string): Promise<void> => | ||
fs | ||
.unlink(filePath) | ||
.catch(error => { | ||
return error.code === 'ENOENT' ? Promise.resolve() : Promise.reject(error) | ||
}) | ||
.then(() => fs.mkdirp(path.dirname(filePath))) | ||
.then(() => fs.writeFile(filePath, data)) | ||
/** | ||
* Write file contents but first delete the file off disk if present. This is a | ||
* useful function when the effect of file delete is needed to trigger some file | ||
* watch/refresh mechanism, such as is the case with VSCode TS declaration files | ||
* inside `@types/` packages. | ||
* | ||
* For more details that motivated this utility refer to the originating issue | ||
* https://github.com/prisma-labs/nexus-prisma/issues/453. | ||
*/ | ||
export const hardWriteFileSync = (filePath: string, data: string): void => { | ||
fs.mkdirpSync(path.dirname(filePath)) | ||
try { | ||
fs.unlinkSync(filePath) | ||
} catch (error) { | ||
if (error.code !== 'ENOENT') throw error | ||
} | ||
fs.writeFileSync(filePath, data) | ||
} | ||
// TODO `any` should be `unknown` but there is a bug (?) | ||
@@ -6,0 +46,0 @@ // preventing that from working, see: |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
155554
3144
159