How to use the graphql-relay.connectionArgs 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 bfwg / relay-gallery / schema / schema.js View on Github external
fields: () => ({
    id: Relay.globalIdField('User'),
    username: {
      type: GraphQL.GraphQLString,
      description: 'the User name',
      resolve: (user) => {
        // console.log(user.username);
        return user.username;
      },
    },
    images: {
      type: ImageConnectionType,
      description: 'A collection of images',
      args: Relay.connectionArgs,
      resolve: (_, args) => Relay.connectionFromPromisedArray(
        (new MyImages()).getAll(),
        args
      ),
    },
  }),
  interfaces: [nodeDefinition.nodeInterface],
github carlipa / aurora-graphql / lib / factories / classes.fields.factory / getQueryFields.js View on Github external
// If the class doesn't have any filter, using `{}` as `filters` field would throw an error
    // This little hack prevents it
    var filtersHolder = !(0, _lodash.keys)(filtersFields).length ? {} : {
      filters: {
        type: filtersType
      }
    };

    // lowerCaseName
    var lcName = className.toLowerCase();

    // All
    queries[pluralName] = {
      type: classesFieldsHelper._connections[lcName],
      args: _extends({}, _graphqlRelay.connectionArgs, filtersHolder, { // Here we destructure our potentially empty object
        orderBy: {
          type: new _graphql.GraphQLList(orderByType)
        }
      }),
      resolve: function resolve(_, args) {
        // Create query
        var query = {};
        (0, _lodash.each)(args.filters, function (filter, fieldName) {
          var safeFilter = (0, _lodash.cloneDeep)(filter);

          // RegExp process
          if (safeFilter.regexp) {
            var matchedRegexp = safeFilter.regexp.match(/\/(.*)\/(\w*)/);

            if (!matchedRegexp) {
              throw new Error('Invalid RegExp at ' + className + '/' + fieldName);
github mikekap / kubelay / graphql / schema.js View on Github external
type: Node,
            args: {
                name: {type: GraphQLString},
            },
            async resolve(root, {name}, {loaders}) {
                return await loaders.nodeByIdLoader.load(name);
            }
        },
        root: {
            async resolve(_) { return {foo: 'bar'}; },
            type: new GraphQLObjectType({
                name: 'RootType',
                fields: {
                    namespaces: {
                        type: AllNamespacesConnection,
                        args: GraphQLRelay.connectionArgs,
                        async resolve(root, args, {loaders}) {
                            const namespaces = await loaders.allNamespaces;
                            return GraphQLRelay.connectionFromArray(namespaces, args);
                        },
                    },
                    kubeNodes: {
                        type: AllNodesConnection,
                        args: GraphQLRelay.connectionArgs,
                        async resolve(root, args, {loaders}) {
                            const nodes = await loaders.allNodes;
                            return GraphQLRelay.connectionFromArray(nodes, args);
                        }
                    },
                    pods: {
                        type: AllPodsConnection,
                        args: {
github mikekap / kubelay / graphql / schema.js View on Github external
root: {
            async resolve(_) { return {foo: 'bar'}; },
            type: new GraphQLObjectType({
                name: 'RootType',
                fields: {
                    namespaces: {
                        type: AllNamespacesConnection,
                        args: GraphQLRelay.connectionArgs,
                        async resolve(root, args, {loaders}) {
                            const namespaces = await loaders.allNamespaces;
                            return GraphQLRelay.connectionFromArray(namespaces, args);
                        },
                    },
                    kubeNodes: {
                        type: AllNodesConnection,
                        args: GraphQLRelay.connectionArgs,
                        async resolve(root, args, {loaders}) {
                            const nodes = await loaders.allNodes;
                            return GraphQLRelay.connectionFromArray(nodes, args);
                        }
                    },
                    pods: {
                        type: AllPodsConnection,
                        args: {
                            ...GraphQLRelay.connectionArgs,
                            namespace: {type: GraphQLString},
                        },
                        async resolve(root, {namespace, ...args}, {loaders}) {
                            const nodes = await loaders.podsByNamespaceLoader.load(namespace || "");
                            return GraphQLRelay.connectionFromArray(nodes, args);
                        }
                    }
github gsasouza / house-automation / packages / server / build / schema / QueryType.js View on Github external
}
      },
      boards: {
        type: _BoardConnection["default"].connectionType,
        args: _objectSpread({}, _graphqlRelay.connectionArgs, {
          search: {
            type: _graphql.GraphQLString
          }
        }),
        resolve: function resolve(_, args, context) {
          return BoardLoader.loadBoards(context, args);
        }
      },
      boardIos: {
        type: _BoardIoConnection["default"].connectionType,
        args: _objectSpread({}, _graphqlRelay.connectionArgs, {
          search: {
            type: _graphql.GraphQLString
          }
        }),
        resolve: function resolve(_, args, context) {
          return BoardIoLoader.loadBoardIos(context, args);
        }
      }
    };
  }
});