How to use the graphql-relay.cursorForObjectInConnection function in graphql-relay

To help you get started, we’ve selected a few graphql-relay examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github milankinen / relei / test / server / data / schema.js View on Github external
resolve: ({localTodoId}) => {
        var todo = getTodo(localTodoId);
        return {
          cursor: cursorForObjectInConnection(getTodos(), todo),
          node: todo,
        };
      }
    },
github ticruz38 / Ambrosia / server / mutation.js View on Github external
resolve: ({orders, order}) => {
        var offset = orders[0].forEach((cursor, index) => {
          console.log('mutation:orderRestaurantEdge:cursorIds', cursor.id);
          if(cursor.id === order.id) return index;
        });
        console.log('mutation:orderRestaurantEdge', order);
        return {
          cursor: cursorForObjectInConnection(orders[0], order),
          node: order
        };
      }
    },
github eyston / relay-composite-network-layer / data / local / schema.js View on Github external
resolve: draft => {
        return {
          cursor: cursorForObjectInConnection(getDrafts(), draft),
          node: draft
        };
      }
    },
github soonlive / relay-cart / data / mutations / addToCartMutation.js View on Github external
mutateAndGetPayload: async({ id, quantity }, session) => {
    logger.info('Invoke addToCartMutation with params:', { id, quantity });
    const cart = cartService.getSessionCart(session);

    const localProductId = fromGlobalId(id).id;
    const product = productService.findById(localProductId);

    const cartEntry = cartService.addToCart(cart, product.productCode, quantity);
    const cartEntryEdge = {
      cursor: cursorForObjectInConnection(cart.entries, cartEntry),
      node: cartEntry,
    };

    return { cartEntry, cartEntryEdge, cart };
  },
});
github morrys / offline-examples / apollo / todo / server / src / resolvers.js View on Github external
addTodo: (root, { input: { id, userId, text } }) => {
      const todoId = addTodo(id, userId, text, false);
      const todo = getTodoOrThrow(todoId);
      const outputFields = {
        todoEdge: {
          cursor: cursorForObjectInConnection([...getTodos(userId)], todo),
          node: todo,
        },
        user: {
          ...getUserOrThrow(userId),
        },
      }
      return outputFields;
    },
    changeTodoStatus: (root, { input: { id, complete, userId } }) => {
github taion / relay-todomvc / src / data / schema.js View on Github external
resolve: ({ todoId }) => {
        const todo = getTodo(todoId);
        return {
          cursor: cursorForObjectInConnection(getTodos(), todo),
          node: todo,
        };
      },
    },
github relay-tools / relay-subscriptions / examples / todo / data / schema.js View on Github external
resolve: ({ localTodoId }) => {
        const todo = getTodo(localTodoId);
        return {
          cursor: cursorForObjectInConnection(getTodos(), todo),
          node: todo,
        };
      },
    },
github jkettmann / universal-react-relay-starter-kit / server / graphql / mutation / CreatePostMutation.js View on Github external
        cursor: db.getPosts().then(posts => cursorForObjectInConnection(posts, newPost)),
        node: newPost,