如何使用 GraphQL + parse.com 构建 Web 应用程序? [英] How to build a web app with GraphQL + parse.com?
问题描述
我想为新应用使用 parse 和 graphQL.它基本上适用于未登录的用户,在这些用户中,人们共享一个链接并在一些临时项目上进行协作.这将计划在某个地点召开会议.
I would like to use parse and graphQL for a new app. It will essentially work with non logged in users, where people share a link and collaborate on some add hoc item. This will plan a meeting at a certain location.
有人知道解决方案或知道解决此问题的方法吗?这似乎是制作应用程序的绝佳方式.
IS anyone aware of a solution or know of a way to approach this? It seems like it would be an awesome way to make apps.
编辑
解析已死
推荐答案
是的,你当然可以构建一个由 Parse 对象支持的 GraphQL 服务器!
Yeah, you could certainly build a GraphQL server that was backed by Parse objects!
在服务器上,您可以像往常一样构建 GraphQL 类型;例如,如果你的 Parse Schema 中有一个 Todo 对象和一个 User 对象(并且使用了来自 npm 的 graphql
和 graphql-relay
),你最终可能会得到对象喜欢
On the server, you'd build out your GraphQL types as usual; for example, if you had a Todo object and a User object in your Parse Schema (and were using graphql
and graphql-relay
from npm), you might end up with objects like
// Build the GraphQL Todo type.
var GraphQLTodo = new GraphQLObjectType({
name: 'Todo',
fields: () => ({
content: {
type: GraphQLString,
resolve: (obj) => obj.get('content')
},
done: {
type: GraphQLBoolean,
resolve: (obj) => obj.get('done')
},
user: {
type: GraphQLUser,
resolve: (obj) => obj.get('user')
}
}),
});
// Build the connection from User to Todo
var {connectionType, edgeType} = connectionDefinitions({
name: 'UserTodo',
nodeType: GraphQLTodo,
});
// Build the GraphQL User type.
var GraphQLUser = new GraphQLObjectType({
name: 'User',
fields: () => ({
todosConnection: {
type: connectionType,
args: connectionArgs,
resolve: (obj, args) => new Parse.Query(Todo).equalTo('user', obj).find()
}
},
});
如果用户已在客户端登录,您可能会将会话令牌传递给服务器,以允许使用该会话令牌进行解析查询(出于 ACL 原因).
If the user has signed in on the client, you could potentially pass up a session token to the server to allow for the parse queries to be made with that session token (for ACL reasons).
这篇关于如何使用 GraphQL + parse.com 构建 Web 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!