How to build a web app with GraphQL + parse.com? [closed]

纵饮孤独 提交于 2019-12-07 14:48:07

问题


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.

EDIT

PARSE IS DEAD


回答1:


Yeah, you could certainly build a GraphQL server that was backed by Parse objects!

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()
    }
  },
});

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).



来源:https://stackoverflow.com/questions/32570272/how-to-build-a-web-app-with-graphql-parse-com

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!