You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 2, 2022. It is now read-only.
-[ ][Order by multiple fields #62](https://github.com/prisma/prisma/issues/62)
23
22
24
23
#### Bug fixes
25
24
26
-
-[Updating Scalar List Values of a Node does not trigger a change of the updatedAt value of a Node #2053](https://github.com/prisma/prisma/issues/2053)
-[Introspect postgres: "Could not connect to database. Prisma Config doesn't have any database connection" #3136](https://github.com/prisma/prisma/issues/3136)
29
-
-[SDL declare order with relation. #3698](https://github.com/prisma/prisma/issues/3698)
30
-
-[Unstable tie breaking for cursor based pagination #3258](https://github.com/prisma/prisma/issues/3258)
31
-
-[Multiple pgRelation on connect mutation #3041](https://github.com/prisma/prisma/issues/3041)
25
+
-[x][Updating Scalar List Values of a Node does not trigger a change of the updatedAt value of a Node #2053](https://github.com/prisma/prisma/issues/2053)
26
+
-[x][Unstable tie breaking for cursor based pagination #3258](https://github.com/prisma/prisma/issues/3258)
-[ ][Introspect postgres: "Could not connect to database. Prisma Config doesn't have any database connection" #3136](https://github.com/prisma/prisma/issues/3136)
32
29
33
30
### Specification phase
34
31
@@ -59,4 +56,4 @@ While the following features are currently not listed in the `Q1/Q2 2019`-sectio
Copy file name to clipboardExpand all lines: cli/packages/prisma-cli-engine/src/Client/Client.ts
+9-6Lines changed: 9 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -114,15 +114,18 @@ export class Client {
114
114
){
115
115
if(!process.env.PRISMA_MANAGEMENT_API_SECRET){
116
116
thrownewError(
117
-
`Server at ${
118
-
this.env.activeCluster.baseUrl
119
-
} requires a cluster secret. Please provide it with the env var PRISMA_MANAGEMENT_API_SECRET`,
117
+
`Server at ${chalk.bold(
118
+
this.env.activeCluster.name
119
+
)
120
+
} requires the Management API secret. Please set the the ${chalk.bold('PRISMA_MANAGEMENT_API_SECRET')} environment variable.
121
+
122
+
Learn more about this error in the docs: https://bit.ly/authentication-and-security-docs`,
120
123
)
121
124
}else{
122
125
thrownewError(
123
-
`Cluster secret in env var PRISMA_MANAGEMENT_API_SECRET does not match for cluster ${
124
-
this.env.activeCluster.name
125
-
}`,
126
+
`Can not authenticate against Prisma server. It seems that your ${chalk.bold('PRISMA_MANAGEMENT_API_SECRET')} environment variable is set incorrectly. Please make sure that it matches the value that was used when the Prisma server was deployed.
127
+
128
+
For more info visit: https://bit.ly/authentication-and-security-docs`,
@@ -18,7 +18,7 @@ The datamodel of your service configuration has two major roles:
18
18
-**Define the underlying database schema** (the defined models are mapped to MonogDB [collections](https://docs.mongodb.com/manual/reference/glossary/#term-collection)).
19
19
- It is the foundation for the **auto-generated CRUD and realtime operations** of your Prisma API. [Learn more](#data-model-vs-prisma-graphql-schema).
20
20
21
-
The datamodel is written in the GraphQL [Schema Definition Language](https://www.prisma.io/blog/graphql-sdl-schema-definition-language-6755bcb9ce51/) (SDL) and stored in one or more [`.prisma`-files](#files). These `.prisma`-files need to be referenced in your [1](5cy7) under the `datamodel` property. For example:
21
+
The datamodel is written using a subset of the GraphQL [Schema Definition Language](https://www.prisma.io/blog/graphql-sdl-schema-definition-language-6755bcb9ce51/) (SDL) and stored in one or more [`.prisma`-files](#files). These `.prisma`-files need to be referenced in your [1](5cy7) under the `datamodel` property. For example:
22
22
23
23
<Codelines="2">
24
24
@@ -33,21 +33,10 @@ datamodel: datamodel.prisma
33
33
34
34
There are several available building blocks to shape your datamodel.
35
35
36
-
- [**Types**](#object-types) consist of multiple [fields](#fields) and typically represent entities from your application domain (e.g. `User`, `Car`, `Order`). Each non-embedded type in your datamodel is mapped to a MongoDB collection and CRUD operations are added to the GraphQL schema.
36
+
- [**Types**](#object-types) consist of multiple [fields](#fields) and typically represent entities from your application domain (e.g. `User`, `Car`, `Order`). Each non-embedded type in your datamodel is mapped to a MongoDB collection and CRUD operations are exposed in the generated Prisam client API.
37
37
- [**Relations**](#relations) describe _relationships_ between types. With MongoDB, a relation can be modeled as an [embedded type](#embedded-types) or as [link relation](#link-relations).
38
38
- [**Directives**](#graphql-directives) covering different use cases such as type constraints or cascading delete behaviour.
39
39
40
-
### Why SDL?
41
-
42
-
The main reason why SDL is used for data modeling is twofold:
43
-
44
-
- SDL is an **intuitive, simple and concise** way to express type definitions and therefore contributes to a **great developer experience**.
45
-
- Using GraphQL SDL to define models that are used as foundation for a GraphQL API is an **idiomatic** approach.
46
-
47
-
There is no hard technical requirement that would dictate the use of SDL and Prisma might allow for other approaches to provide model definitions in the future.
48
-
49
-
> To learn more about the SDL, you can check out the official [GraphQL documentation](http://graphql.org/learn/schema/#type-language) or read the actual [specification](http://facebook.github.io/graphql/draft/#sec-Type-System).
50
-
51
40
## Example
52
41
53
42
A simple example `datamodel.prisma` file:
@@ -132,62 +121,11 @@ Applying changes... (22/22)
132
121
Applying changes... 0.4s
133
122
```
134
123
135
-
## Datamodel vs Prisma GraphQL schema
136
-
137
-
When starting out with GraphQL and Prisma, the amount of SDL-files you're working with can be confusing. Yet, it's crucial to understand what the role of each of them is.
138
-
139
-
Looking only at Prisma, there are two SDL-files that are relevant:
140
-
141
-
- The **datamodel** containing the _model definitions_ for your Prisma APIs, typically called `datamodel.prisma`.
142
-
- The **Prisma GraphQL schema** defining the actual CRUD/realtime _operations_ of the service's API, typically called `prisma.graphql`.
143
-
144
-
The Prisma database database schema is generated based on the datamodel:
145
-
146
-

147
-
148
-
The illustration shows a simplified version of the generated Prisma GraphQL schema, you can find the full schema [here](https://gist.github.com/gc-codesnippets/f302c104f2806f9e13f41d909e07d82d).
149
-
150
-
<Collapse title="Learn more about GraphQL schemas">
151
-
152
-
A [GraphQL schema](https://www.prisma.io/blog/graphql-server-basics-the-schema-ac5e2950214e/) defines the operations of a GraphQL API. It effectively is a collection of _types_ written in SDL (SDL also supports primitives like interfaces, enums, union types and more, you can learn everything about GraphQL's type system [here](http://graphql.org/learn/schema/#type-system)).
153
-
154
-
A GraphQL schema has three special _root types_: `Query`, `Mutation` and `Subscription`. These types define the _entry points_ for the API and define what operations the API will accept. To learn more about GraphQL schema, check out this [article](https://www.prisma.io/blog/graphql-server-basics-the-schema-ac5e2950214e/).
155
-
156
-
</Collapse>
157
-
158
-
### The datamodel
159
-
160
-
The datamodel is written manually by the developers of the Prisma service. It defines the models and structures the developer wants to use in their API.
161
-
162
-
Strictly speaking, the **datamodel is not a valid GraphQL schema** because it does not contain any of GraphQL's root types (`Query`, `Mutation`, `Subscription`) and therefore does not define any API operations.
163
-
164
-
The datamodel only serves as _foundation_ for the generation of the actual GraphQL schema that defines the GraphQL API of your Prisma service.
165
-
166
-
### The Prisma GraphQL schema
167
-
168
-
The Prisma GraphQL schema can be dowloaded from a Prisma service using the `graphql-schema` generator in your 1:
169
-
170
-
```yml
171
-
generate:
172
-
- generator: `graphql-schema`
173
-
output: ./prisma-schema
174
-
```
175
-
176
-
Now you can run `prisma generate` and the Prisma CLI will stored the Prisma GraphQLS schema in `./prisma-schema/prisma.graphql`.
177
-
178
-
### A note on the application schema
179
-
180
-
If you've already looked into building your own GraphQL server based on Prisma, you might have come across another `.graphql`-file which is referred to as your **application schema** (typically called `schema.graphql` or `app.graphql`).
181
-
182
-
This is a valid GraphQL schema (meaning it contains the `Query`, `Mutation` and `Subscription` root types) that defines the API of your _application layer_. In contrast to Prisma's _generic_ CRUD API, the application layer's API should expose _domain-specific_ operations that are tailored to the needs of your client applications.
183
-
184
-
The application layer uses Prisma as a _data access layer_ and delegates incoming requests to the service's Prisma API where they're actually resolved against the database.
185
-
186
124
## Files
187
125
188
126
You can write your datamodel in a single `.prisma`-file or split it accross multiple ones.
189
127
190
-
The `.prisma`-files containing the datamodel need to be specified in your 1 under the `datamodel` property. For example:
128
+
The `.prisma`-files containing the datamodel need to be referenced in your `prisma.yml` under the `datamodel` property. For example:
191
129
192
130
```yml
193
131
datamodel:
@@ -214,8 +152,6 @@ A type has a _name_ and one or multiple [_fields_](#fields). Type names can only
214
152
215
153
An instantiation of a type is called a _node_. This term refers to a node inside your _data graph_.
216
154
217
-
Every type you define in your datamodel will be available as an analogous type in the generated _Prisma GraphQL schema_.
218
-
219
155
### Defining an object type
220
156
221
157
A object type is defined in the datamodel with the keyword `type`:
@@ -373,7 +309,7 @@ type User {
373
309
374
310
### Type modifiers
375
311
376
-
In a field definition, a type can be annotated with a _type modifier_. GraphQL supports two type modifiers:
312
+
In a field definition, a type can be annotated with a _type modifier_. SDL supports two type modifiers:
377
313
378
314
- **Required fields:** Annotate the type with a `!`, e.g. `name: String!`
379
315
- **Lists:** Annotate the type with a pair of enclosing `[]`, e.g. `friends: [User]`
@@ -392,7 +328,7 @@ type Article {
392
328
393
329
Notice the two `!` type modifiers, here is what they express:
394
330
395
-
- The first `!` type modifier (right after `String`) means that no item in the list can be `null`, e.g. this value for `tags` would not be valid: `["Software", null, "GraphQL"]`
331
+
- The first `!` type modifier (right after `String`) means that no item in the list can be `null`, e.g. this value for `tags` would not be valid: `["Software", null, "Prisma"]`
396
332
- The second `!` type modifier (after the closing square bracket) means that the list itself can never be `null`, it might be _empty_ though. Consequently, `null` is not a valid value for the `tags` field but `[]` is.
397
333
398
334
#### Required
@@ -448,7 +384,7 @@ For every field that's annotated with `@unique`, you're able to query the corres
448
384
449
385
For example, considering the above datamodel, you can now retrieve a particular `User` node by its `email` address:
More database constraints will be added soon. Please join the discussion in this [feature request](https://github.com/prisma/prisma/issues/728) if you have wish to see certain constraints implemented in Prisma.
@@ -523,14 +448,6 @@ Values for fields annotated with the `@id`-directive have the following properti
523
448
* Always start with a (lowercase) letter, e.g. `c`
Notice that all model types in the Prisma GraphQL schema will implement the `Node` interface. This is what the `Node` interface looks like:
527
-
528
-
```graphql
529
-
interface Node {
530
-
id: ID! @id
531
-
}
532
-
```
533
-
534
451
#### System fields: `createdAt` and `updatedAt`
535
452
536
453
The datamodel further provides two special directives which you can add to your fields:
@@ -689,7 +606,7 @@ Note that in this case the relation needs to be annotated with the [`@relation`
689
606
690
607
For a _to-one_ relation field, you can configure whether it is _required_ or _optional_. The `!` type modifier means that this field can never be `null`. A field for the address of a user would therefore be of type `Address` or `Address!`.
691
608
692
-
Nodes for a type that contains a required _to-one_ relation field can only be created using a [nested mutation](qwe2#nested-mutations) to ensure the respective field will not be `null`.
609
+
Nodes for a type that contains a required _to-one_ relation field can only be created using a [nested mutation](rsc6#nested-object-writes) to ensure the respective field will not be `null`.
693
610
694
611
Consider again the following relation:
695
612
@@ -708,7 +625,7 @@ type Car {
708
625
709
626
A `Car` can never be created without a `User` and the other way around because that would violate the required constraint. You therefore need to create both at the same time using a declarative nested write:
Note that a _to-many_ relation field is always set to required. For example, a field that contains many user addresses always uses the type `[Address!]!` and can never be of type `[Address!]`, `[Address]!` or `[Address]`.
@@ -876,13 +776,6 @@ Let's investigate the deletion behaviour for the three types:
876
776
- the related `Blog` node continues to exist and the deleted `Comment` node is removed from its `comments` list.
877
777
- the related `User` node continues to exist and the deleted `Comment` node is removed from its `comments` list.
878
778
879
-
### Generated API operations for relations
880
-
881
-
The relations that are included in your schema affect the available operations in the [Prisma API](/use-prisma-api). Here is an overview of the generated CRUD and realtime operations for every relation in your Prisma API:
882
-
883
-
- [Relation queries](qwe1#querying-data-across-relations) allow you to query data across types or aggregated for a relation (note that this is also possible using [Relay](https://facebook.github.io/relay/)'s [connection model](qwe1#connection-queries)).
884
-
- [Nested mutations](qwe2#nested-mutations) allow you to create, connect, update, upsert and delete multiple related nodes within the same mutation.
885
-
- [Relation subscriptions](qwe3#relation-subscriptions) allow you to get notified of changes to a relation.
886
779
887
780
## SDL directives
888
781
@@ -952,12 +845,12 @@ In this section, we describe further SDL features that are not yet supported for
952
845
953
846
### Interfaces
954
847
955
-
"Like many type systems, GraphQL supports interfaces. An interface is an abstract type that includes a certain set of fields that a type must include to implement the interface."Fromtheofficial [GraphQLDocumentation](http://graphql.org/learn/schema/#interfaces)
848
+
"Like many type systems, [SDL] supports interfaces. An interface is an abstract type that includes a certain set of fields that a type must include to implement the interface."Fromtheofficial [Documentation](http://graphql.org/learn/schema/#interfaces)
956
849
957
850
TolearnmoreaboutwhenandhowinterfacesarecomingtoPrisma, check out this [feature request](https://github.com/prisma/prisma/issues/83).
958
851
959
852
### Union types
960
853
961
-
"Union types are very similar to interfaces, but they don't get to specify any common fields between the types."Fromtheofficial [GraphQLDocumentation](http://graphql.org/learn/schema/#union-types)
854
+
"Union types are very similar to interfaces, but they don't get to specify any common fields between the types."Fromtheofficial [Documentation](http://graphql.org/learn/schema/#union-types)
962
855
963
856
TolearnmoreaboutwhenandhowuniontypesarecomingtoPrisma, check out this [feature request](https://github.com/prisma/prisma/issues/165).
0 commit comments