Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Commit

Permalink
Merge branch 'beta'
Browse files Browse the repository at this point in the history
  • Loading branch information
mavilein committed May 15, 2019
2 parents 7422c06 + 4f12238 commit 5d6e09c
Show file tree
Hide file tree
Showing 196 changed files with 11,609 additions and 5,580 deletions.
1 change: 0 additions & 1 deletion cli/packages/prisma-cli-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,3 @@ Prisma has a community of thousands of amazing developers and contributors. Welc

Contributions are **welcome and extremely helpful** 🙌
Please refer [to the contribution guide](https://github.com/graphcool/prisma/blob/master/CONTRIBUTING.md) for more information.

2 changes: 1 addition & 1 deletion cli/packages/prisma-cli-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"devDependencies": {
"@types/aws-lambda": "^0.0.17",
"@types/fs-extra": "^5.0.0",
"@types/graphql": "^14.0.3",
"@types/graphql": "14.0.3",
"@types/node": "^8.0.22",
"@types/semver": "^5.5.0",
"faker": "^4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion cli/packages/prisma-cli-core/src/commands/delete/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class Delete extends Command {
this.definition.getWorkspace(),
)

const prettyName = `${chalk.bold(serviceName)}@${stage}`
const prettyName = `${chalk.bold(this.definition.endpoint!)}`

if (!force) {
await this.askForConfirmation(prettyName)
Expand Down
2 changes: 1 addition & 1 deletion cli/packages/prisma-cli-engine/src/StatusChecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class StatusChecker {
globalBin,
hashDate,
})
const secret = 'epiGheezoh5eogoachiu9tie9'
const secret = 'loTheeChaxaiPhahsa8Aifiel'

const hash = crypto
.createHmac('sha256', secret)
Expand Down
6 changes: 3 additions & 3 deletions cli/packages/prisma-datamodel/__tests__/parser/directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ for (const parser of parsersToTest) {
lastName: String!
}
type UserToUser @linkTable {
type UserToUser @relationTable {
A: User!
B: User!
}
Expand All @@ -222,10 +222,10 @@ for (const parser of parsersToTest) {
const { types } = parser.instance.parseFromSchemaString(model)

const userType = SdlExpect.type(types, 'User')
expect(userType.isLinkTable).toBe(false)
expect(userType.isRelationTable).toBe(false)

const linkType = SdlExpect.type(types, 'UserToUser')
expect(linkType.isLinkTable).toBe(true)
expect(linkType.isRelationTable).toBe(true)
})
})
}
4 changes: 2 additions & 2 deletions cli/packages/prisma-datamodel/__tests__/renderer/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe(`Renderer test`, () => {
],
name: 'User',
isEmbedded: false,
isLinkTable: false,
isRelationTable: false,
isEnum: false,
indices: [],
directives: [],
Expand Down Expand Up @@ -118,7 +118,7 @@ describe(`Renderer test`, () => {
const type: IGQLType = {
name: 'Test',
isEmbedded: false,
isLinkTable: false,
isRelationTable: false,
directives: typeDirectives,
isEnum: false,
fields: [scalarField, arrayField],
Expand Down
2 changes: 1 addition & 1 deletion cli/packages/prisma-datamodel/__tests__/renderer/baseV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe(`Renderer datamodel v1.1 test`, () => {
const type: IGQLType = {
name: 'Test',
isEmbedded: false,
isLinkTable: false,
isRelationTable: false,
isEnum: false,
fields: [field1, field2, field3, field4],
comments: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe(`Renderer directives test`, () => {
const type: IGQLType = {
name: 'Test',
isEmbedded: true,
isLinkTable: false,
isRelationTable: false,
// This will be ignored since we are dealing with an embedded type
databaseName: 'testType',
isEnum: false,
Expand Down Expand Up @@ -80,7 +80,7 @@ describe(`Renderer directives test`, () => {
const type: IGQLType = {
name: 'Test',
isEmbedded: false,
isLinkTable: false,
isRelationTable: false,
databaseName: 'testType',
isEnum: false,
fields: [field1, field2, field3, field4],
Expand Down Expand Up @@ -130,7 +130,7 @@ describe(`Renderer directives test`, () => {
const type: IGQLType = {
name: 'User',
isEmbedded: false,
isLinkTable: false,
isRelationTable: false,
isEnum: false,
fields: [
idField,
Expand Down Expand Up @@ -192,7 +192,7 @@ describe(`Renderer directives test`, () => {
const type: IGQLType = {
name: 'User',
isEmbedded: false,
isLinkTable: false,
isRelationTable: false,
isEnum: false,
fields: [
idField,
Expand Down Expand Up @@ -226,7 +226,7 @@ describe(`Renderer directives test`, () => {
lastName: String!
}
type UserToUser @linkTable {
type UserToUser @relationTable {
A: User!
B: User!
}`)
Expand All @@ -238,7 +238,7 @@ describe(`Renderer directives test`, () => {
const type: IGQLType = {
name: 'User',
isEmbedded: false,
isLinkTable: false,
isRelationTable: false,
isEnum: false,
fields: [idField, lastNameField],
indices: [],
Expand All @@ -250,7 +250,7 @@ describe(`Renderer directives test`, () => {
const linkType: IGQLType = {
name: 'UserToUser',
isEmbedded: false,
isLinkTable: true,
isRelationTable: true,
isEnum: false,
fields: [
new GQLOneRelationField('A', type, true),
Expand Down
2 changes: 1 addition & 1 deletion cli/packages/prisma-datamodel/src/datamodel/directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export abstract class DirectiveKeys {
public static index = 'index'
public static indexes = 'indexes'
public static sequence = 'sequence'
public static linkTable = 'linkTable'
public static relationTable = 'relationTable'
public static scalarList = 'scalarList'

public static isId = 'id'
Expand Down
2 changes: 1 addition & 1 deletion cli/packages/prisma-datamodel/src/datamodel/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export interface IGQLType {
* the two foreign key fields. The indices are hidden
* when introspecting.
*/
isLinkTable: boolean
isRelationTable: boolean

/**
* The name of this type.
Expand Down
10 changes: 5 additions & 5 deletions cli/packages/prisma-datamodel/src/datamodel/parser/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ export default abstract class DefaultParser {
* Checks if the given type is marked as link table.
* @param type
*/
protected isLinkTable(type: any): boolean {
return this.hasDirective(type, DirectiveKeys.linkTable)
protected isRelationTable(type: any): boolean {
return this.hasDirective(type, DirectiveKeys.relationTable)
}

/**
Expand All @@ -432,15 +432,15 @@ export default abstract class DefaultParser {

const databaseName = this.getDatabaseTypeName(type)
const isEmbedded = this.isEmbedded(type)
const isLinkTable = this.isLinkTable(type)
const isRelationTable = this.isRelationTable(type)
const directives = this.parseDirectives(type)
const indices = this.parseIndices(type, fields)

return {
name: type.name.value,
fields,
isEnum: false,
isLinkTable,
isRelationTable,
isEmbedded,
databaseName,
directives,
Expand Down Expand Up @@ -489,7 +489,7 @@ export default abstract class DefaultParser {
name: type.name.value,
fields: values,
isEnum: true,
isLinkTable: false,
isRelationTable: false,
isEmbedded: false,
directives,
comments: [],
Expand Down
12 changes: 6 additions & 6 deletions cli/packages/prisma-datamodel/src/datamodel/renderer/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export default abstract class Renderer {
return { name: DirectiveKeys.isEmbedded, arguments: {} }
}

protected createIsLinkTableTypeDirective(type: IGQLType) {
return { name: DirectiveKeys.linkTable, arguments: {} }
protected createIsRelationTableTypeDirective(type: IGQLType) {
return { name: DirectiveKeys.relationTable, arguments: {} }
}

protected createDatabaseNameTypeDirective(type: IGQLType) {
Expand Down Expand Up @@ -118,8 +118,8 @@ export default abstract class Renderer {
return type.isEmbedded
}

protected shouldCreateIsLinkTableTypeDirective(type: IGQLType) {
return type.isLinkTable
protected shouldCreateIsRelationTableTypeDirective(type: IGQLType) {
return type.isRelationTable
}

protected shouldCreateDatabaseNameTypeDirective(type: IGQLType) {
Expand All @@ -140,8 +140,8 @@ export default abstract class Renderer {
if (this.shouldCreateDatabaseNameTypeDirective(type)) {
typeDirectives.push(this.createDatabaseNameTypeDirective(type))
}
if (this.shouldCreateIsLinkTableTypeDirective(type)) {
typeDirectives.push(this.createIsLinkTableTypeDirective(type))
if (this.shouldCreateIsRelationTableTypeDirective(type)) {
typeDirectives.push(this.createIsRelationTableTypeDirective(type))
}
if (this.shouldRenderIndexDirectives(type)) {
this.createIndexDirectives(type, typeDirectives)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,126 @@ type UserSpace {
}"
`;

exports[`Introspects relations-4424/mysql correctly: relations-4424 - legacy datamodel 1`] = `
"type Customer {
cartItems: [CustomerCartItem] @relation(name: \\"CustomerCartItemsRelation\\")
createdAt: DateTime!
emailId: String! @unique
id: ID! @unique
mobileNumber: String
name: String
uid: String! @unique
updatedAt: DateTime!
wishlists: [CustomerWishlist] @relation(name: \\"CustomerWishlistsRelation\\")
}
type CustomerCartItem {
addedAtPrice: Int!
createdAt: DateTime!
customer: Customer @relation(name: \\"CustomerCartItemsRelation\\")
id: ID! @unique
product: Product @relation(name: \\"ProductsInCartRelation\\")
quantity: Int!
savedForLater: Boolean! @default(value: false)
updatedAt: DateTime!
}
type CustomerWishlist {
customer: Customer @relation(name: \\"CustomerWishlistsRelation\\")
id: ID! @unique
listName: String!
}
type Post {
createdAt: DateTime!
id: ID! @unique
text: String
updatedAt: DateTime!
}
type PostsProductsRelation @relationTable {
post: Post!
product: Product!
}
type Product {
brand: String!
cartedIn: [CustomerCartItem] @relation(name: \\"ProductsInCartRelation\\")
createdAt: DateTime!
description: String!
id: ID! @unique
name: String!
ratingsDistribution: [Int]
tags: [String]
updatedAt: DateTime!
}
type WishlistedProductsRelation @relationTable {
product: Product!
wishlist: CustomerWishlist!
}"
`;

exports[`Introspects relations-4424/mysql correctly: relations-4424 - v1.1 datamodel 1`] = `
"type Customer {
cartItems: [CustomerCartItem] @relation(name: \\"CustomerCartItemsRelation\\")
createdAt: DateTime! @createdAt
emailId: String! @unique
id: ID! @id
mobileNumber: String
name: String
uid: String! @unique
updatedAt: DateTime! @updatedAt
wishlists: [CustomerWishlist] @relation(name: \\"CustomerWishlistsRelation\\")
}
type CustomerCartItem {
addedAtPrice: Int!
createdAt: DateTime! @createdAt
customer: Customer @relation(name: \\"CustomerCartItemsRelation\\")
id: ID! @id
product: Product @relation(name: \\"ProductsInCartRelation\\")
quantity: Int!
savedForLater: Boolean! @default(value: false)
updatedAt: DateTime! @updatedAt
}
type CustomerWishlist {
customer: Customer @relation(name: \\"CustomerWishlistsRelation\\")
id: ID! @id
listName: String!
}
type Post {
createdAt: DateTime! @createdAt
id: ID! @id
text: String
updatedAt: DateTime! @updatedAt
}
type PostsProductsRelation @relationTable {
post: Post!
product: Product!
}
type Product {
brand: String!
cartedIn: [CustomerCartItem] @relation(name: \\"ProductsInCartRelation\\")
createdAt: DateTime! @createdAt
description: String!
id: ID! @id
name: String!
ratingsDistribution: [Int] @scalarList(strategy: RELATION)
tags: [String] @scalarList(strategy: RELATION)
updatedAt: DateTime! @updatedAt
}
type WishlistedProductsRelation @relationTable {
product: Product!
wishlist: CustomerWishlist!
}"
`;

exports[`Introspects scalars/mysql correctly: scalars - legacy datamodel 1`] = `
"type LotsOfRequiredScalars {
boolean: Boolean!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Introspector Type with scalar lists and existing schema 1`] = `
"type User @linkTable @pgTable(name: \\"users\\") {
"type User @pgTable(name: \\"users\\") @relationTable {
id: Int! @unique
asked: [Question] @relation(name: \\"question_asked\\")
answered: [Question] @relation(name: \\"question_answer\\")
}
type Question @linkTable @pgTable(name: \\"questions\\") {
type Question @pgTable(name: \\"questions\\") @relationTable {
id: Int! @unique
asker: User! @pgColumn(name: \\"asker_id\\") @relation(name: \\"question_asked\\")
answerer: User @pgColumn(name: \\"answerer_id\\") @relation(name: \\"question_answer\\")
Expand Down
Loading

0 comments on commit 5d6e09c

Please sign in to comment.