How to use the graphql-relay.connectionFromArray 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 artsy / metaphysics / src / schema / v2 / me / saved_artworks.ts View on Github external
.catch(() => {
        // For some users with no favourites, Gravity produces an error of "Collection Not Found".
        // This can cause the Gravity endpoint to produce a 404, so we will intercept the error
        // and return an empty list instead.
        return connectionFromArray([], options)
      })
  },
github graphql / swapi-graphql / src / schema / connections.js View on Github external
resolve: async (obj, args) => {
      const array = await getObjectsFromUrls(obj[prop] || []);
      return {
        ...connectionFromArray(array, args),
        totalCount: array.length,
      };
    },
  };
github the-control-group / authx / packages / authx / src / graphql / GraphQLUser.ts View on Github external
async resolve(user, args, { realm, authorization: a, pool }: Context) {
        const tx = await pool.connect();
        try {
          return a
            ? connectionFromArray(
                await filter(await user.grants(tx), grant =>
                  grant.isAccessibleBy(realm, a, tx)
                ),
                args
              )
            : null;
        } finally {
          tx.release();
        }
      }
    },
github facebook / relay / examples / star-wars / data / schema.js View on Github external
      resolve: (faction, args) => connectionFromArray(
        faction.ships.map((id) => getShip(id)),
        args
      ),
    },
github the-control-group / authx / packages / authx / src / graphql / query / roles.ts View on Github external
WHERE
          replacement_record_id IS NULL
          ${args.includeDisabled ? "" : "AND enabled = true"}
        `
      );

      if (!ids.rows.length) {
        return [];
      }

      const roles = await Role.read(
        tx,
        ids.rows.map(({ id }) => id)
      );

      return connectionFromArray(
        await filter(roles, role => role.isAccessibleBy(realm, a, tx)),
        args
      );
    } finally {
      tx.release();
    }
  }
};
github guigrpa / mady / src / server / graphql / gqlServer.js View on Github external
    resolve: (base, args) => connectionFromArray(db.getKeys(), args),
  };
github amazeeio / lagoon / services / api-legacy / src / schema / queries / site.js View on Github external
resolve: async (_, args) => {
    const sites = (await getAllSites())
      .filter((site) => args.createdAfter ? new Date(args.createdAfter).getTime() < new Date(site.created).getTime() : true)
      .filter((site) => args.environmentType ? args.environmentType == site.siteEnvironment : true);      
    return connectionFromArray(sites, args);
  },
};