如何使用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类型.例如,如果您在解析模式中有一个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屋!