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

Commit

Permalink
Merge branch 'alpha' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
mavilein committed May 15, 2019
2 parents 4f12238 + ec678fe commit 738ee5f
Show file tree
Hide file tree
Showing 254 changed files with 10,244 additions and 3,137 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "prisma-query"]
path = server/prisma-rs/libs/prisma-query
url = https://github.com/prisma/prisma-query.git
[submodule "server/.buildkite/build-cli"]
path = server/.buildkite/build-cli
url = https://github.com/prisma/build-cli.git
4 changes: 2 additions & 2 deletions 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.2.0",
"@types/node": "^8.0.22",
"@types/semver": "^5.5.0",
"faker": "^4.1.0",
Expand Down Expand Up @@ -89,7 +89,7 @@
"figures": "^2.0.0",
"fs-extra": "^7.0.0",
"globby": "^8.0.1",
"graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0",
"graphql": "^14.3.0",
"graphql-config": "2.2.1",
"graphql-config-extension-prisma": "0.2.5",
"graphql-playground-middleware-express": "^1.6.2",
Expand Down
3 changes: 1 addition & 2 deletions cli/packages/prisma-cli-engine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,11 @@
"chalk": "^2.3.0",
"charm": "^1.0.2",
"debug": "^3.1.0",
"graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0",
"directory-tree": "2.2.1",
"figures": "^2.0.0",
"find-up": "^3.0.0",
"fs-extra": "^7.0.0",
"graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0",
"graphql": "^14.3.0",
"graphql-request": "^1.5.0",
"inquirer": "^6.2.0",
"isomorphic-fetch": "^2.2.1",
Expand Down
4 changes: 2 additions & 2 deletions cli/packages/prisma-client-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
"zen-observable": "^0.8.10"
},
"devDependencies": {
"@types/graphql": "14.0.3",
"@types/graphql": "14.2.0",
"@types/prettier": "1.16.1",
"ava": "^0.25.0",
"graphql": "^14.0.2",
"graphql": "^14.3.0",
"semantic-release": "^15.10.4",
"tslint": "5.11.0",
"tslint-config-standard": "8.0.1",
Expand Down
10 changes: 6 additions & 4 deletions cli/packages/prisma-client-lib/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
GraphQLResolveInfo,
GraphQLOutputType,
print,
Kind,
ASTNode,
} from 'graphql'

import { Operation } from '../types'
Expand Down Expand Up @@ -77,13 +79,13 @@ export function printDocumentFromInfo(info: GraphQLResolveInfo) {
const fragments = Object.keys(info.fragments).map(
fragment => info.fragments[fragment],
)
const doc = {
kind: 'Document',
const doc: ASTNode = {
kind: Kind.DOCUMENT,
definitions: [
{
kind: 'OperationDefinition',
kind: Kind.OPERATION_DEFINITION,
operation: 'query',
selectionSet: info.fieldNodes[0].selectionSet,
selectionSet: info.fieldNodes[0].selectionSet!,
},
...fragments,
],
Expand Down
2 changes: 1 addition & 1 deletion cli/packages/prisma-datamodel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"typescript": "^3.2.2"
},
"dependencies": {
"graphql": "^14.0.2",
"graphql": "^14.3.0",
"pluralize": "^7.0.0",
"popsicle": "10"
},
Expand Down
2 changes: 1 addition & 1 deletion cli/packages/prisma-generate-schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"typescript": "^3.2.2"
},
"dependencies": {
"graphql": "^14.0.2",
"graphql": "^14.3.0",
"pluralize": "^7.0.0",
"popsicle": "10",
"prisma-datamodel": "1.23.0-alpha.1"
Expand Down
2 changes: 1 addition & 1 deletion cli/scripts/test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -e
set -ex

cd cli/packages/prisma-datamodel
yarn
Expand Down
2 changes: 1 addition & 1 deletion cli/scripts/test_ci.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -e
set -ex

#
# Detect change
Expand Down
54 changes: 11 additions & 43 deletions cli/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,10 @@
"@types/minimatch" "*"
"@types/node" "*"

"@types/graphql@14.0.3":
version "14.0.3"
resolved "https://registry.yarnpkg.com/@types/graphql/-/graphql-14.0.3.tgz#389e2e5b83ecdb376d9f98fae2094297bc112c1c"
integrity sha512-TcFkpEjcQK7w8OcrQcd7iIBPjU0rdyi3ldj6d0iJ4PPSzbWqPBvXj9KSwO14hTOX2dm9RoiH7VuxksJLNYdXUQ==
"@types/graphql@14.2.0":
version "14.2.0"
resolved "https://registry.yarnpkg.com/@types/graphql/-/graphql-14.2.0.tgz#74e1da5f2a4a744ac6eb3ed57b48242ea9367202"
integrity sha512-lELg5m6eBOmATWyCZl8qULEOvnPIUG6B443yXKj930glXIgwQirIBPp5rthP2amJW0YSzUg2s5sfgba4mRRCNw==

"@types/jest@^20.0.8":
version "20.0.8"
Expand Down Expand Up @@ -2561,7 +2561,7 @@ debug@^4.0.0, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1:
dependencies:
ms "^2.1.1"

debuglog@*, debuglog@^1.0.1:
debuglog@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492"
integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI=
Expand Down Expand Up @@ -4056,10 +4056,10 @@ graphql-tools@^4.0.3:
iterall "^1.1.3"
uuid "^3.1.0"

"graphql@^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0", graphql@^14.0.2:
version "14.2.1"
resolved "https://registry.yarnpkg.com/graphql/-/graphql-14.2.1.tgz#779529bf9a01e7207b977a54c20670b48ca6e95c"
integrity sha512-2PL1UbvKeSjy/lUeJqHk+eR9CvuErXoCNwJI4jm3oNFEeY+9ELqHNKO1ZuSxAkasPkpWbmT/iMRMFxd3cEL3tQ==
graphql@^14.3.0:
version "14.3.0"
resolved "https://registry.yarnpkg.com/graphql/-/graphql-14.3.0.tgz#34dd36faa489ff642bcd25df6c3b4f988a1a2f3e"
integrity sha512-MdfI4v7kSNC3NhB7cF8KNijDsifuWO2XOtzpyququqaclO8wVuChYv+KogexDwgP5sp7nFI9Z6N4QHgoLkfjrg==
dependencies:
iterall "^1.2.2"

Expand Down Expand Up @@ -4415,7 +4415,7 @@ import-local@^1.0.0:
pkg-dir "^2.0.0"
resolve-cwd "^2.0.0"

imurmurhash@*, imurmurhash@^0.1.4:
imurmurhash@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
integrity sha1-khi5srkoojixPcT7a21XbyMUU+o=
Expand Down Expand Up @@ -5895,11 +5895,6 @@ lockfile@^1.0.4:
dependencies:
signal-exit "^3.0.2"

lodash._baseindexof@*:
version "3.1.0"
resolved "https://registry.yarnpkg.com/lodash._baseindexof/-/lodash._baseindexof-3.1.0.tgz#fe52b53a1c6761e42618d654e4a25789ed61822c"
integrity sha1-/lK1OhxnYeQmGNZU5KJXie1hgiw=

lodash._baseuniq@~4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash._baseuniq/-/lodash._baseuniq-4.6.0.tgz#0ebb44e456814af7905c6212fa2c9b2d51b841e8"
Expand All @@ -5908,33 +5903,11 @@ lodash._baseuniq@~4.6.0:
lodash._createset "~4.0.0"
lodash._root "~3.0.0"

lodash._bindcallback@*:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e"
integrity sha1-5THCdkTPi1epnhftlbNcdIeJOS4=

lodash._cacheindexof@*:
version "3.0.2"
resolved "https://registry.yarnpkg.com/lodash._cacheindexof/-/lodash._cacheindexof-3.0.2.tgz#3dc69ac82498d2ee5e3ce56091bafd2adc7bde92"
integrity sha1-PcaayCSY0u5ePOVgkbr9Ktx73pI=

lodash._createcache@*:
version "3.1.2"
resolved "https://registry.yarnpkg.com/lodash._createcache/-/lodash._createcache-3.1.2.tgz#56d6a064017625e79ebca6b8018e17440bdcf093"
integrity sha1-VtagZAF2JeeevKa4AY4XRAvc8JM=
dependencies:
lodash._getnative "^3.0.0"

lodash._createset@~4.0.0:
version "4.0.3"
resolved "https://registry.yarnpkg.com/lodash._createset/-/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26"
integrity sha1-D0ZZ+7CddRlPqeK4imZE02PJ/iY=

lodash._getnative@*, lodash._getnative@^3.0.0:
version "3.9.1"
resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5"
integrity sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=

lodash._root@~3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._root/-/lodash._root-3.0.1.tgz#fba1c4524c19ee9a5f8136b4609f017cf4ded692"
Expand Down Expand Up @@ -6085,11 +6058,6 @@ lodash.property@^4.4.2:
resolved "https://registry.yarnpkg.com/lodash.property/-/lodash.property-4.4.2.tgz#da07124821c6409d025f30db8df851314515bffe"
integrity sha1-2gcSSCHGQJ0CXzDbjfhRMUUVv/4=

lodash.restparam@*:
version "3.6.1"
resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805"
integrity sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=

lodash.result@^4.5.2:
version "4.5.2"
resolved "https://registry.yarnpkg.com/lodash.result/-/lodash.result-4.5.2.tgz#cb45b27fb914eaa8d8ee6f0ce7b2870b87cb70aa"
Expand Down Expand Up @@ -8463,7 +8431,7 @@ readable-stream@~1.1.10:
isarray "0.0.1"
string_decoder "~0.10.x"

readdir-scoped-modules@*, readdir-scoped-modules@^1.0.0:
readdir-scoped-modules@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/readdir-scoped-modules/-/readdir-scoped-modules-1.0.2.tgz#9fafa37d286be5d92cbaebdee030dc9b5f406747"
integrity sha1-n6+jfShr5dksuuve4DDcm19AZ0c=
Expand Down
2 changes: 1 addition & 1 deletion server/.envrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ export PRISMA_BINARY_CONFIG_PATH=$(pwd)/prisma-rs/prisma.yml

## Rust specific variables
export SCHEMA_INFERRER_PATH=$(pwd)/images/schema-inferrer-bin/target/prisma-native-image/schema-inferrer-bin
export PRISMA_DATA_MODEL_PATH=$(pwd)/prisma-rs/schema.prisma
export PRISMA_SDL_PATH=$(pwd)/prisma-rs/schema.prisma
export RUST_LOG=actix_web=debug,prisma=debug
export RUST_BACKTRACE=1
4 changes: 4 additions & 0 deletions server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ dev-postgres:
docker-compose -f docker-compose/postgres/dev-postgres.yml up -d --remove-orphans
cp ./docker-compose/postgres/prisma.yml ./prisma.yml

dev-postgres-native:
docker-compose -f docker-compose/postgres/dev-postgres.yml up -d --remove-orphans
cp ./docker-compose/postgres-native/prisma.yml ./prisma.yml

dev-mongo:
docker-compose -f docker-compose/mongo/dev-mongo.yml up -d --remove-orphans
cp ./docker-compose/mongo/prisma.yml ./prisma.yml
Expand Down
5 changes: 3 additions & 2 deletions server/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,11 @@ lazy val apiConnectorMongo = connectorProject("api-connector-mongo")
oldOptions.filterNot(_ == "-Xfatal-warnings")
})

lazy val apiConnectorSQLiteNative = connectorProject("api-connector-sqlite-native")
lazy val apiConnectorNative = connectorProject("api-connector-native")
.dependsOn(apiConnector)
.dependsOn(prismaRsBinding)
.dependsOn(apiConnectorSQLite)
.dependsOn(apiConnectorPostgres)


// ##################
Expand Down Expand Up @@ -519,7 +520,7 @@ lazy val apiConnectorProjects = List(
apiConnectorPostgres,
apiConnectorMongo,
apiConnectorSQLite,
apiConnectorSQLiteNative
apiConnectorNative
)

lazy val allConnectorProjects = deployConnectorProjects ++ apiConnectorProjects ++ Seq(connectorUtils, connectorShared)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.prisma.api.connector.native

import java.sql.Driver

import com.prisma.api.connector.postgres.PostgresApiConnector
import com.prisma.api.connector.sqlite.SQLiteApiConnector
import com.prisma.api.connector.{ApiConnector, DataResolver, DatabaseMutactionExecutor}
import com.prisma.config.DatabaseConfig
import com.prisma.shared.models.{ConnectorCapabilities, Project, ProjectIdEncoder}

import scala.concurrent.{ExecutionContext, Future}

trait Backup {
def driver: Driver
}

case class SqliteBackup(driver: Driver) extends Backup
case class PostgresBackup(driver: Driver) extends Backup

case class ApiConnectorNative(config: DatabaseConfig, backup: Backup)(implicit ec: ExecutionContext) extends ApiConnector {
override def initialize(): Future[Unit] = Future.unit
override def shutdown(): Future[Unit] = Future.unit

override def databaseMutactionExecutor: DatabaseMutactionExecutor = {
backup match {
case SqliteBackup(driver) => {
val base = SQLiteApiConnector(config, driver)
NativeDatabaseMutactionExecutor(base.databaseMutactionExecutor.slickDatabase)
}
case PostgresBackup(driver) => {
val base = PostgresApiConnector(config, driver)
NativeDatabaseMutactionExecutor(base.databaseMutactionExecutor.slickDatabase)
}
}
}

override def dataResolver(project: Project): DataResolver = NativeDataResolver(project)
override def masterDataResolver(project: Project): DataResolver = NativeDataResolver(project)
override def projectIdEncoder: ProjectIdEncoder = ProjectIdEncoder('_')

override val capabilities = ConnectorCapabilities.sqliteNative
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.prisma.api.connector.sqlite.native
package com.prisma.api.connector.native

import com.google.protobuf.ByteString
import com.prisma.api.connector._
Expand All @@ -13,13 +13,11 @@ import prisma.protocol.ValueContainer.PrismaValue.GraphqlId

import scala.concurrent.{ExecutionContext, Future}

case class SQLiteNativeDataResolver(delegate: DataResolver)(implicit ec: ExecutionContext) extends DataResolver {
case class NativeDataResolver(project: Project)(implicit ec: ExecutionContext) extends DataResolver {
import NativeUtils._
import com.prisma.shared.models.ProjectJsonFormatter._
import com.prisma.api.helpers.LimitClauseHelper._

override def project: Project = delegate.project

override def getNodeByWhere(where: NodeSelector, selectedFields: SelectedFields): Future[Option[PrismaNode]] = Future {
val projectJson = Json.toJson(project)
val input = prisma.protocol.GetNodeByWhereInput(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.prisma.api.connector.sqlite.native
package com.prisma.api.connector.native
import com.google.protobuf.ByteString
import com.prisma.api.connector.jdbc.{NestedDatabaseMutactionInterpreter, TopLevelDatabaseMutactionInterpreter}
import com.prisma.api.connector.jdbc.impl._
Expand All @@ -17,7 +17,7 @@ import slick.jdbc.TransactionIsolation

import scala.concurrent.{ExecutionContext, Future}

case class SQLiteDatabaseMutactionExecutor(
case class NativeDatabaseMutactionExecutor(
slickDatabaseArg: SlickDatabase
)(implicit ec: ExecutionContext)
extends DatabaseMutactionExecutor {
Expand All @@ -26,8 +26,13 @@ case class SQLiteDatabaseMutactionExecutor(
import NativeUtils._

override def executeRaw(project: Project, query: String): Future[JsValue] = {
val action = JdbcActionsBuilder(project, slickDatabaseArg).executeRaw(query)
runAttached(project, action)
val envelope = prisma.protocol.ExecuteRawInput(
header = prisma.protocol.Header("ExecuteRawInput"),
dbName = project.dbName,
query = query
)

Future(NativeBinding.execute_raw(envelope))
}

override def executeNonTransactionally(mutaction: TopLevelDatabaseMutaction) = execute(mutaction)
Expand Down
Loading

0 comments on commit 738ee5f

Please sign in to comment.