<commit_before>
import {
    GraphQLBoolean,
    GraphQLList,
    GraphQLInt,
    GraphQLNonNull,
    GraphQLObjectType,
    GraphQLInputObjectType,
    GraphQLSchema,
    GraphQLString,
} from 'graphql';

import {
    connectionArgs,
    connectionDefinitions,
    connectionFromArray,
    fromGlobalId,
    globalIdField,
    mutationWithClientMutationId,
    nodeDefinitions,
} from 'graphql-relay';

import {
    Person,
    Field,
    Note,
    GroupCall,
    GroupCallInvitation
} from './models';

var {nodeInterface, nodeField} = nodeDefinitions(
    (globalId) => {
        var {type, id} = fromGlobalId(globalId);
        if (type === 'Person')
            return Person.get(id);
        else if (type === 'GroupCall')
            return GroupCall.get(id);
        else
            return null;
    },
    (obj) => {
        if (obj instanceof Person)
            return personType;
        else if (obj instanceof GroupCall)
            return groupCallType;
        else
            return null;
    }
)

var inviteeType = new GraphQLObjectType({
    name: 'GroupCallInvitee',
    description: 'A single invitee to a group call',
    fields: () => ({
        person: {
            type: new GraphQLNonNull(personType),
            resolve: (invitee) => { return Person.get(invitee.personId); }
        },
        signedUp: { type: new GraphQLNonNull(GraphQLBoolean) },
        attended: { type: new GraphQLNonNull(GraphQLBoolean) }
    })
})

var groupCallType = new GraphQLObjectType({
    name: 'GroupCall',
    description: 'A group call with a bunch of people',
    fields: () => ({
        id: globalIdField('GroupCall'),
        scheduledTime: { type: new GraphQLNonNull(GraphQLString) },
        maxSignups: { type: new GraphQLNonNull(GraphQLInt) },
        invitees: { type: new GraphQLNonNull(new GraphQLList(inviteeType)) }
    })
})

var groupCallInvitationType = new GraphQLObjectType({
    name: 'GroupCallInvitation',
    description: 'An invitation to a number of group calls.',
    fields: () => ({
        id: globalIdField('GroupCallInvitation'),
        topic: { type: new GraphQLNonNull(GraphQLString) },
        groupCalls: {
            type: new GraphQLNonNull(new GraphQLList(groupCallType)),
            resolve: (groupCallInvitation) => {
                return groupCallInvitation.groupCalls || []
            }
        }
    })
})

var personType = new GraphQLObjectType({
    name: 'Person',
    description: 'A person that has at some point signed up',
    fields: () => ({
        id: globalIdField('Person'),
        email: { type: new GraphQLNonNull(GraphQLString) },
    }),
    interfaces: [nodeInterface],
});


var groupCallInputType = new GraphQLInputObjectType({
    name: 'GroupCallInput',
    fields: {
        scheduledTime: { type: new GraphQLNonNull(GraphQLString) },
        maxSignups: { type: new GraphQLNonNull(GraphQLInt) }
    }
})

var CreateGroupCallInvitation = mutationWithClientMutationId({
    name: 'CreateGroupCallInvitation',
    inputFields: {
        topic: { type: new GraphQLNonNull(GraphQLString) },
        groupCalls: { type: new GraphQLList(groupCallInputType) }
    },
    outputFields: {
        groupCallInvitation: {
            type: groupCallInvitationType,
            resolve: (payload) => payload
        }
    },
    mutateAndGetPayload: async ({topic, groupCalls}) => {
        var newGroupCallInvitation = new GroupCallInvitation({
            topic: topic
        });
        newGroupCallInvitation.groupCalls = []

        groupCalls.map(call => {
            var newGroupCall = new GroupCall({
                scheduledTime: call.scheduledTime,
                maxSignups: call.maxSignups,
                signups: []
            })
            newGroupCall.groupCallInvitation = newGroupCallInvitation;
            newGroupCallInvitation.groupCalls.push(newGroupCall);
        })

        return newGroupCallInvitation.saveAll()
    },
});

var mutationType = new GraphQLObjectType({
    name: 'Mutation',
    fields: () => ({
        createGroupCallInvitation: CreateGroupCallInvitation
    })
});

var queryType = new GraphQLObjectType({
    name: 'Query',
    fields: () => ({
        node: nodeField,
        groupCallInvitation: {
            type: groupCallInvitationType,
            args: {
                id: { type: new GraphQLNonNull(GraphQLString) }
            },
            resolve: (root, {id}) => {
                return GroupCallInvitation.get(id);
            }
        },
        groupCall: {
            type: groupCallType,
            args: {
                id: { type: new GraphQLNonNull(GraphQLString) }
            },
            resolve: (root, {id}) => {
                return GroupCall.get(id);
            }
        }
    }),
});

export var Schema = new GraphQLSchema({
    query: queryType,
    // Uncomment the following after adding some mutation fields:
    mutation: mutationType
});<commit_msg>Minimal schema<commit_after>
import {
  GraphQLBoolean,
  GraphQLList,
  GraphQLInt,
  GraphQLNonNull,
  GraphQLObjectType,
  GraphQLInputObjectType,
  GraphQLSchema,
  GraphQLString,
} from 'graphql';

import {
  connectionArgs,
  connectionDefinitions,
  connectionFromArray,
  fromGlobalId,
  globalIdField,
  mutationWithClientMutationId,
  nodeDefinitions,
} from 'graphql-relay';

import {
  GroupCallInvitation
} from './models';

var {nodeInterface, nodeField} = nodeDefinitions(
  (globalId) => {
    var {type, id} = fromGlobalId(globalId);
    if (type === 'GroupCallInvitation')
      return GroupCallInvitation.get(id)
    else
      return null;
  },
  (obj) => {
    if (obj instanceof GroupCallInvitation)
      return groupCallInvitationType;
    else
      return null;
  }
);

var groupCallInvitationType = new GraphQLObjectType({
  name: 'GroupCallInvitation',
  description: 'An invitation to a number of group calls.',
  fields: () => ({
    id: globalIdField('GroupCallInvitation'),
    topic: {
      type: GraphQLString
    }
  }),
  interfaces: [nodeInterface]
})

var queryType = new GraphQLObjectType({
  name: 'Query',
  fields: () => ({
    groupCallInvitation: {
      type: groupCallInvitationType,
      args: {
        id: { type: new GraphQLNonNull(GraphQLString) }
      },
      resolve: (root, {id}) => {
        return GroupCallInvitation.get(id);
      }
    },
    node: nodeField
  }),
});

export var Schema = new GraphQLSchema({
  query: queryType,
});
{'fraction_non_alphanumeric': 0.1098661686896981, 'fraction_numerical': 0.0, 'mean_word_length': 2.504362050163577, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6385905', 'n_tokens_mistral': 1871, 'n_tokens_neox': 1876, 'n_words': 417}