{"size": 709, "ext": "js", "max_stars_repo_path": "examples/graphql-tools.js", "max_stars_repo_name": "dijonkitchen/graphql-resolve-batch", "max_stars_repo_stars_event_min_datetime": "2017-02-28T01:50:21.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-09T08:42:56.000Z", "max_issues_repo_path": "examples/graphql-tools.js", "max_issues_repo_name": "dijonkitchen/graphql-resolve-batch", "max_issues_repo_issues_event_min_datetime": "2017-03-09T02:30:11.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-15T14:39:24.000Z", "max_forks_repo_path": "examples/graphql-tools.js", "max_forks_repo_name": "dijonkitchen/graphql-resolve-batch", "max_forks_repo_forks_event_min_datetime": "2017-03-09T02:13:13.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-06T10:54:26.000Z"}
{"max_stars_count": 272, "max_issues_count": 12, "max_forks_count": 15, "avg_line_length": 17.2926829268, "max_line_length": 75, "alphanum_fraction": 0.6276445698}
import { makeExecutableSchema } from 'graphql-tools';
import { createBatchResolver } from '../src/batch';
import { getUser, getFriendsForUsers } from './data';

const typeDefs = `
type User {
  id: Int
  name: String
  friends(limit: Int!): [User]
}

type Query {
  user(id: Int!): User
}

schema {
  query: Query
}
`;

const resolvers = {
  User: {
    friends: createBatchResolver((users, { limit }) => {
      console.log('Resolving friends 👫'); // eslint-disable-line no-console
      return getFriendsForUsers(users, limit);
    }),
  },
  Query: {
    user(_, { id }) {
      return getUser(id);
    },
  },
};

const Schema = makeExecutableSchema({
  typeDefs,
  resolvers,
});

export default Schema;
