-
Notifications
You must be signed in to change notification settings - Fork 859
MongoDB Connector #1643
Comments
I would like to work on this! Where is a good place to start looking? How to wrap head around the task and break it into its constituent parts? Please provide some guidelines if possible, would be much appreciated! Thanks for your work on this project, it is very cool, reminds me of RESTHeart ;) |
@ookangzheng Have a look at the project README file. It says "Prisma can be used for MySQL Databases out of the box" ;) |
Hi @alexandrakl it would be great to collaborate on this! The first step is to map out the kind of queries that are particularly well supported by Mongo as well as queries currently supported by Prisma that does not fit the document model. Based on this we can design the API for Document-flavoured GraphQL. Feel free to dump your thoughts in this thread so we can get the conversation going :-) |
@alexandrakl @sorenbs I'd love to work with you all on this. |
Here's an outline of some things we need to consider:
Take a look at https://github.com/graphcool/prisma/issues/1340 for the API spec for the MySQL conenctor @GilUpstream @alexandrakl and anyone who want to contribute. It would be great if you could start mapping out some of these questions in this thread. |
Top level fieldsFor each type with an
Query
field name generationThe The Mutation
Examples:
Detailstype Query {
user(where: UserWhereUniqueInput): User
users(
where: UserWhereInput
orderBy: UserOrderByInput
skip: Int
before: String
after: String
first: Int
last: Int
): [User!]!
usersConnection(
where: UserWhereInput
orderBy: UserOrderByInput
skip: Int
before: String
after: String
first: Int
last: Int
): UserConnection!
}
type Mutation {
createUser(data: UserCreateInput!): User!
updateUser(data: UserUpdateInput!, where: UserWhereUniqueInput!): User
deleteUser(where: UserWhereUniqueInput!): User
upsertUser(where: UserWhereUniqueInput!, create: UserCreateInput!, update: UserUpdateInput!): User
updateManyUsers(data: UserUpdateInput!, where: UserWhereInput!): BatchPayload
deleteManyUsers(where: UserWhereInput!): BatchPayload
} query fieldswhereSame filter as for the SQL connector, except relational filters only work for scalar
relation to embedded type
orderBySame enum as for SQL connector
skipInteger specifying the number of documents to skip beforeid of the document to start from, going backwards: afterid of the document to start from: firstInteger limiting the number of documents to return: lastInteger limiting the number of documents to return: Nested MutationsMongo supports arbitrarily nested documents but has no understanding of relations between documents. Prisma supports two ways to model related data:
In the same way, When is a type embedded?In Prisma a type is considered to be embedded when it has no
handling of relations
scalar lists
|
There needs the be a common api or interface so one can switch to different connectors. |
That's a great point @juicycleff We plan to support database specific APIs as well a a Core API. Most of the database specific APIs will have significant overlap with the core API making it easy to switch between connectors. For Mongo and SQL specifically we will be able to have almost 100% overlap :-) |
If you need some inspiration for a GraphQL type system of a document database, have a look at cruddl. It's a TypeScript library that serves a GraphQL API similar the one of prisma, but it uses ArangoDB as database (might also be interesting for #1645). It is built to embrace the possibilities of document databasees like embedding. We invented four kinds of object types to support different use cases of embedding and relating objects - like when ids should be auto-generated and whether omitted fields in update mutations should remove them or leave them unchanged. Considering the similarities between cruddl and prisma, we would look forward to work towards a common "standard" GraphQL API for document databases. |
Have a look at graphql-compose it's a toolkit for construction of complex GraphQL schemas. Provides bunch of plugins for type generation. Allows to build your own plugins/helper-functions for type construction and modification and graphql-compose-mongoose a Mongoose model converter to GraphQL types with resolvers. They also have type generator plugins for elasticsearch and aws |
@sorenbs in my opinion, we should consider a
|
@duytai i agree. The term embedded type is used here only to describe a certain way to lay out your data. Prismas SQL connector has no understanding of that term and neither will the Mongo connector. The final api will be almost identical apart from less powerful filters. |
any updates on this? |
Is someone working on this at the moment? |
An update for this note:
Transactions will be supported in 4.0 |
In Mongodb joins/relations are not recommended for cases where the related documents don't change often, better said, we have a lot more of queries than mutations, for example, suppose that our I believe embedded types can be handled in the same way Prisma handles relations, but every embedded document should contain an |
@sorenbs Have you considered including any mongoose-specific abstractions like virtuals and references/reference population (i.e. using references as an alternative to embedded documents)? I've really liked utilizing mongoose's populate operator to keep document sizes to a predictable limit, avoid arrays growing without bound, and normalize the data as much as possible. Virtuals/getters and setters are more of a nice-to-have but have still proven to be handy in certain situations, acting like Redux selectors. I know the purpose of the mongodb connector isn't to be a mongoosejs connector, however I anticipate a large number of developers having likely interacted with mongoosejs as much if not more than the mongodb API directly, so having some familiar features might make the adoption process easier. Also, do you plan to support GeoJSON object types for geospatial queries? They've been indispensable in a few projects and I'd really hope for them to be supported. |
+1 for GeoJSON. My primary use case for mongo is to enable efficient geospatial queries. These complex queries can be done with mongo directly, but the ability to resolve GeoJSON data through Prisma would be very handy. |
While I appreciate the passion displayed by the community in the comments here, this thread is a place to discuss design decisions for the upcoming MongoDB connector. I have deleted a number of comments that were off-topic. If you are interested in these other topics, feel free to reach out to me in slack or open a conversation in the forum. |
Take a look at mongodb references. Equivalent to foreign keys in pgsql. It was also previously mentioned that multi-document transactions is supported by mongo 4.0. |
Thanks @agolomoodysaada! We will most likely support multi-document transactions in the future. Keep in mind that this is a feature that currently does not support sharding, and even when implemented in MongoDB 4.2 will incur a performance penalty that might be too high for many applications. References similarly does not support sharding, and I don't know of any public plans to support it in the future. |
As we are getting closer to the first beta release of the Mongo connector, we are looking for early adopters to take it for a spin. If you are planning to build an application using Prisma and MongoDB, now is a good time to get involved to make sure the MongoDB connector covers all your needs. If you are interested, please ping @do4gr here or in the Prisma slack 🙏 |
@do4gr , I'm interested in testing it out... any docs I can follow? |
The documentation how to set up Prisma to use Mongo and how to use the new features can be found here: https://github.com/prisma/Mongo-Connector-Preview |
Also interested in testing out the MongoDB connector. |
To those trying out this new connector, it would be great to leave links if your work is open source. Hoping to try this myself soon. |
@do4gr I'd like to test the MongoDB connector and hope to use it in production on a project I'm currently building. |
The current documentation how to use it can be found here: https://github.com/prisma/Mongo-Connector-Preview We'll release full documentation in the next days. |
I was waiting a long time for this, and I must say prisma is doing a great job, I was wondering if there is support for multi-document ACID transactions that were introduced in mongodb v4. I can see that the current documentation is using mongodb v3.6 not v4+. Thanks! |
Hey @vibhanshu909, we haven't done extensive testing on the compatibility with Mongo 4.0. The core is structured in a way that we should be able to introduce transactionality with 4.0 fairly easily. The challenge is in properly testing this for correctness and performance afterwards. This is why we are still holding off on this. But I would expect us to enable this at some point. |
Wow amazing, wish have support mongo 4.0 soon 👍 |
You can track the progress on multi-document ACID transactions in #3785 |
Nothing about GeoJson? this future is mandatory for many MongoDB projects. |
This feature requests serves as a central place to discuss development and progress for the MongoDB connector. Please contribute in the comments below. I will update the top comment as consensus forms.
The text was updated successfully, but these errors were encountered: