src/schema.js
function jsonSchemaTypeToGraphQL(jsonSchemaType, schemaName) {
  if (jsonSchemaType === "array") {
    if (graphQLObjectTypes[schemaName]) {
      return new GraphQLList(graphQLObjectTypes[schemaName]);
    } else {
      const translated = {
        pilots: "people",
        characters: "people",
        residents: "people"
      }[schemaName];

      if (! translated) {
        throw new Error(`no type ${schemaName}`);
      }

      const type = graphQLObjectTypes[translated];

      if (! type) {
        throw new Error(`no GraphQL type ${schemaName}`);
      }

      return new GraphQLList(type);
    }
  }

  return {
    string: GraphQLString,
    date: GraphQLString,
    integer: GraphQLInt,
  }[jsonSchemaType];
}
function jsonSchemaTypeToGraphQL(jsonSchemaType, schemaName) {
  if (jsonSchemaType === "array") {
    if (graphQLObjectTypes[schemaName]) {
      return new GraphQLList(graphQLObjectTypes[schemaName]);
    } else {
      const translated = {
        pilots: "people",
        characters: "people",
        residents: "people"
      }[schemaName];

      if (! translated) {
        throw new Error(`no type ${schemaName}`);
      }

      const type = graphQLObjectTypes[translated];

      if (! type) {
        throw new Error(`no GraphQL type ${schemaName}`);
      }

      return new GraphQLList(type);
    }
  }

  return {
    string: GraphQLString,
    date: GraphQLString,
    integer: GraphQLInt,
  }[jsonSchemaType];
}
function jsonSchemaTypeToGraphQL ( jsonSchemaType , schemaName ) { if ( jsonSchemaType === "array" ) { if ( graphQLObjectTypes [ schemaName ] ) { return new GraphQLList ( graphQLObjectTypes [ schemaName ] ) ; } else { const translated = { pilots : "people" , characters : "people" , residents : "people" } [ schemaName ] ; if ( ! translated ) { throw new Error ( ` ${ schemaName } ` ) ; } const type = graphQLObjectTypes [ translated ] ; if ( ! type ) { throw new Error ( ` ${ schemaName } ` ) ; } return new GraphQLList ( type ) ; } } return { string : GraphQLString , date : GraphQLString , integer : GraphQLInt , } [ jsonSchemaType ] ; }
Convert the JSON Schema types to the actual GraphQL types in our schema
Convert the JSON Schema types to the actual GraphQL types in our schema