Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions api/worldWeatherOnline.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ const {
GraphQLObjectType,
GraphQLString,
GraphQLList,
GraphQLInt,
} = graphql;

// World Weather Online API



const WwoAPIType = new GraphQLObjectType({
name: "WwoAPI",
fields: () => ({
data: { type: DataType }
})
request: { type: GraphQLList(RequestType) },
weather: { type: GraphQLList(HourlyType) }
}),
});

const DataType = new GraphQLObjectType({
Expand Down Expand Up @@ -66,8 +70,10 @@ const AstronomyType = new GraphQLObjectType({
});

const HourlyType = new GraphQLObjectType({
name: "hourly",
name: "Hourly",
fields: () => ({
waterTemperature: {type: GraphQLString},
swellHeight: {type: GraphQLString},
windspeedMiles: { type: GraphQLString },
windspeedKmph: { type: GraphQLString },
winddir16Point: { type: GraphQLString },
Expand Down
12 changes: 8 additions & 4 deletions models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,14 @@ const UserSchema = new Schema({
type: String,
required: false
},
favoriteBeach: {
type: String,
required: false
}
favoriteBeach: [
{
name: {
type: String,
required: false
}
}
]
});

module.exports = mongoose.model("User", UserSchema);
45 changes: 0 additions & 45 deletions npm-debug.log

This file was deleted.

146 changes: 63 additions & 83 deletions schema/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ const {
GraphQLList,
GraphQLNonNull,
GraphQLFloat,
GraphQLInputObjectType,
GraphQLInterfaceType
GraphQLInputObjectType
} = graphql;

const ratingsType = new GraphQLObjectType({
name: "Object",
name: "Ratings",
fields: () => ({
_id: { type: GraphQLID },
user: { type: GraphQLInt },
Expand Down Expand Up @@ -187,6 +186,14 @@ const LocationType = new GraphQLObjectType({

// Future UserType for logged in user control

let favoriteType = new GraphQLInputObjectType({
name: "favoriteType",
fields: () => ({
cognitoUserId: { type: new GraphQLNonNull(GraphQLString) },
name: { type: GraphQLString() }
})
});

const UserType = new GraphQLObjectType({
name: "User",
fields: () => ({
Expand All @@ -201,7 +208,11 @@ const UserType = new GraphQLObjectType({
regionInput: { type: GraphQLString },
beachInput: { type: GraphQLString },
persona: { type: GraphQLString },
<<<<<<< HEAD
favoriteBeach: { type: GraphQLString }
=======
favoriteBeach: { type: new GraphQLList(favoriteType) }
>>>>>>> 8499477ce76c971fe2e1eda065f0d5a61251d6c9
})
});

Expand All @@ -222,6 +233,13 @@ const RootQuery = new GraphQLObjectType({
return User.findById(args.id);
}
},
favoriteBeach: {
type: new GraphQLList(favoriteType),
args: { id: { type: GraphQLID } },
resolve(parent, args) {
return favoriteType.findById(args.id);
}
},
filterUser: {
type: new GraphQLList(UserType),
args: getGraphQLQueryArgs(UserType),
Expand All @@ -248,6 +266,13 @@ const RootQuery = new GraphQLObjectType({
return Location.find({});
}
},
location:{
type: new GraphQLList(LocationType),
args: {ID: {type: GraphQLID}},
resolve(parent, args){
return Location.find({ID: args.ID}).catch(error =>{console.log(error)})
}
},
users: {
type: new GraphQLList(UserType),
resolve(parent, args) {
Expand All @@ -257,21 +282,20 @@ const RootQuery = new GraphQLObjectType({
}
});

// const ratingsTypeMut = new GraphQLInputObjectType({
// name: "beachRatings",
// fields: () => ({
// _id: { type: GraphQLID },
// user: { type: GraphQLInt },
// rating: { type: GraphQLInt }
// })
// });
const ratingsTypeMut = new GraphQLInputObjectType({
name: "beachRatings",
fields: () => ({
user: { type: GraphQLInt },
rating: { type: GraphQLInt }
})
});

// const favbeachTypeMut = new GraphQLInputObjectType({
// name: "beachRatings",
// fields: () => ({
// name: { type: GraphQLID }
// })
// });
const favbeachTypeMut = new GraphQLInputObjectType({
name: "beachRatings",
fields: () => ({
name: { type: GraphQLID }
})
});

const Mutation = new GraphQLObjectType({
name: "Mutation",
Expand All @@ -290,7 +314,11 @@ const Mutation = new GraphQLObjectType({
regionInput: { type: GraphQLString },
beachInput: { type: GraphQLString },
persona: { type: GraphQLString },
<<<<<<< HEAD
favoriteBeach: { type: GraphQLString }
=======
favoriteBeach: { type: new GraphQLList(favoriteType) }
>>>>>>> 8499477ce76c971fe2e1eda065f0d5a61251d6c9
},
async resolve(parent, args) {
let user = new User({
Expand All @@ -305,7 +333,11 @@ const Mutation = new GraphQLObjectType({
regionInput: args.regionInput,
beachInput: args.beachInput,
persona: args.persona,
<<<<<<< HEAD
favoriteBeach: args.favoriteBeach
=======
favoriteBeach: args.favoriteType
>>>>>>> 8499477ce76c971fe2e1eda065f0d5a61251d6c9
});

let mUser = await hb(user);
Expand All @@ -327,7 +359,7 @@ const Mutation = new GraphQLObjectType({
regionInput: { type: GraphQLString },
beachInput: { type: GraphQLString },
persona: { type: GraphQLString },
favoriteBeach: { type: GraphQLString }
favoriteBeach: { type: new GraphQLList(favoriteType) }
},
resolve(root, args) {
console.log(
Expand All @@ -350,72 +382,20 @@ const Mutation = new GraphQLObjectType({
});
});
}
},
updateRatings: {
type: LocationType,
args: {
ID: { type: GraphQLID },
input: { type: ratingsTypeMut }
},
async resolve(root, args) {

const ratingUpdate = await Location.findOneAndUpdate({ID:args.ID}, {$push:{Ratings: args.input}}, {new:true} );
return(ratingUpdate);

}
}
// updateBeach: {
// type: LocationType,
// args: {
// ID: { type: GraphQLID },
// DISTRICT: { type: GraphQLString },
// CountyNum: { type: GraphQLInt },
// COUNTY: { type: GraphQLString },
// NameMobileWeb: { type: GraphQLString },
// LocationMobileWeb: { type: GraphQLString },
// DescriptionMobileWeb: { type: GraphQLString },
// PHONE_NMBR: { type: GraphQLString },
// PARKING: { type: GraphQLString },
// DSABLDACSS: { type: GraphQLString },
// RESTROOMS: { type: GraphQLString },
// VISTOR_CTR: { type: GraphQLString },
// DOG_FRIENDLY: { type: GraphQLString },
// EZ4STROLLERS: { type: GraphQLString },
// PCNC_AREA: { type: GraphQLString },
// CAMPGROUND: { type: GraphQLString },
// SNDY_BEACH: { type: GraphQLString },
// DUNES: { type: GraphQLString },
// RKY_SHORE: { type: GraphQLString },
// BLUFF: { type: GraphQLString },
// STRS_BEACH: { type: GraphQLString },
// PTH_BEACH: { type: GraphQLString },
// BLFTP_TRLS: { type: GraphQLString },
// BLFTP_PRK: { type: GraphQLString },
// WLDLFE_VWG: { type: GraphQLString },
// TIDEPOOL: { type: GraphQLString },
// VOLLEYBALL: { type: GraphQLString },
// FISHING: { type: GraphQLString },
// BOATING: { type: GraphQLString },
// LIST_ORDER: { type: GraphQLString },
// GEOGR_AREA: { type: GraphQLString },
// LATITUDE: { type: GraphQLFloat },
// LONGITUDE: { type: GraphQLFloat },
// REGION: { type: GraphQLString },
// Photo_1: { type: GraphQLString },
// Photo_2: { type: GraphQLString },
// Photo_3: { type: GraphQLString },
// Photo_4: { type: GraphQLString },
// Bch_whlchr: { type: GraphQLString },
// BIKE_PATH: { type: GraphQLString },
// BT_FACIL_TYPE: { type: GraphQLString }
// // Ratings: { type: ratingsTypeMut }
// },
// resolve(root, args) {
// return new Promise((resolve, reject) => {
// User.findOneAndUpdate(
// {
// NameMobileWeb: args.NameMobileWeb
// },
// args,
// {
// new: true,
// useFindAndModify: false
// }
// ).exec((err, res) => {
// console.log(res);
// if (err) reject(err);
// else resolve(res);
// });
// });
// }
// }
}
});

Expand Down
Empty file added schema/userInputType.js
Empty file.