paljs / create-nexus-type Goto Github PK
View Code? Open in Web Editor NEWThis repo moved under pal CLI
Home Page: https://paljs.com/cli/cnt
This repo moved under pal CLI
Home Page: https://paljs.com/cli/cnt
Got the error
Cannot read property 'replace' of undefined
Downgraded to 1.2.2 and it worked again.
Love this tool so far, so thanks for your work here! I was wondering about the possibility of merging in the generated types with existing custom ones that may be unrelated to prisma2
.
I see that the current behavior allows me to define additional files in src/types
as long as the names don't collide and they won't be overwritten. However, running cnt
does overwrite the index.ts
file, which forces me to re-export the custom files each time.
Would it be possible to allow for custom types alongside the generated ones in the files, or at least add all files in the types
directory back to index.ts
once generation has finished?
Thanks for a sweet lib. Make stuff easy to work with.
Found an issue with a field name model
inside of a model.
Just checked the source fast and I think I saw the issue. Leaving this here for now and dropping a PR if I manage to sort it out later on.
Example not working:
model Car {
id Int @id
model_year Int @default(0)
license_plate String @default("")
brand Brand
model Model
}
This works:
model Car {
id Int @id
model_year Int @default(0)
license_plate String @default("")
brand Brand
car_model Model
}
schema:
/// DEMO
model Some {
/// PK
id String @default(cuid()) @id
/// MARK
remark String?
}
output:
import { objectType, extendType } from 'nexus'
export const Some = objectType({
name: 'Some',
definition(t) {
t.model.///()
t.model.id()
t.model.///()
t.model.remark()
},
})
export const someQuery = extendType({
type: 'Query',
definition(t) {
t.crud.some()
t.crud.somes({ filtering: true, ordering: true })
},
})
export const someMutation = extendType({
type: 'Mutation',
definition(t) {
t.crud.createOneSome()
t.crud.updateOneSome()
t.crud.upsertOneSome()
t.crud.deleteOneSome()
t.crud.updateManySome()
t.crud.deleteManySome()
},
})
From v0.20 nexus has breaking changes. Are there any plans to support it?
Getting the following error while processing the Prisma2 schema shown below. When I remove the Comment and Mention models from the schema, it works fine.
The Prisma2 schema below works fine using prisma2 dev
and prisma2 lift
under Preview 19, but fails using cnt
.
Command:
npx cnt -mq -f -o --js --mjs
Error:
/Users/scottwallace/Developer/hushright/graphql/node_modules/create-nexus-type/src/cli.js:81
} else if (fileContent !== '' && !filteredArray[0].includes('//')) {
^
TypeError: Cannot read property 'includes' of undefined
at lines.map.line (/Users/scottwallace/Developer/hushright/graphql/node_modules/create-nexus-type/src/cli.js:81:57)
at Array.map (<anonymous>)
at /Users/scottwallace/Developer/hushright/graphql/node_modules/create-nexus-type/src/cli.js:43:10
at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)
Prisma Schema:
generator photon {
provider = "photonjs"
}
datasource db {
provider = "mysql"
url = "[redacted connection url]"
}
model User {
id Int @id @default(autoincrement())
displayname String @unique
uid String @unique
photoURL String
description String?
following User[] @relation("follow")
followedBy User[] @relation("follow")
posts Post[]
emotions Emotion[]
shares Share[]
mentionsOfUser Mention[] @relation("mentionsOfUser")
mentionsOfBy Mention[] @relation("mentionsByUser")
pagerank Float @default(0)
emotionalScore Float @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
deleted Boolean @default(false)
blocked Boolean @default(false)
blockedOn DateTime?
}
model Post {
id Int @id @default(autoincrement())
author User
text String
links WebLink[]
hashtags Hashtag[]
comments Comment[]
images Image[]
emotions Emotion[]
shares Share[]
mentions Mention[]
pagerank Float @default(0)
emotionalScore Float @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
deleted Boolean @default(false)
}
model WebLink {
id Int @id @default(autoincrement())
orginalUrl String
href String
hostname String
secure Boolean
origin String
validated Boolean @default(false)
pagerank Float @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
deleted Boolean @default(false)
}
model Emotion {
id Int @id @default(autoincrement())
emotionType Int @default(0)
score Int @default(0)
emoter User
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
deleted Boolean @default(false)
}
model Hashtag {
id Int @id @default(autoincrement())
name String
pagerank Float @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
deleted Boolean @default(false)
}
model Image {
id Int @id @default(autoincrement())
url String
validated Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
deleted Boolean @default(false)
}
model Share {
id Int @id @default(autoincrement())
sharer User
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
deleted Boolean @default(false)
}
model Comment {
id Int @id @default(autoincrement())
body String
pagerank Float @default(0)
emotionalScore Float @default(0)
author User
post Post
links WebLink[]
hashtags Hashtag[]
images Image[]
emotions Emotion[]
mentions Mention[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
deleted Boolean @default(false)
}
model Mention {
id Int @id @default(autoincrement())
ofUser User @relation("mentionsOfUser")
byUser User @relation("mentionsByUser")
inPost Post?
inComment Comment?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
deleted Boolean @default(false)
}
Any help appreciated.
Updated to the latest "^1.2.1" and now when I run npx cnt -s -mq -f -o
I get "convertSchema is not a function". This has been working up till this upgrade. Downgrading for now.
RUN cnt -s -mq -m -q -f -o --js
generate ok. But generated code Error.
export const User = objectType({
^^^^^^
SyntaxError: Unexpected token 'export'
...
Possible reasons ๏ผ
fileContent += `export const ${model.name} = objectType({
...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.