-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added event schemas, models and queries
- Loading branch information
Showing
6 changed files
with
196 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
type Product { | ||
""" | ||
The ID of an object | ||
""" | ||
id: ID! | ||
_id: String | ||
title: String | ||
} | ||
|
||
type Event { | ||
id: ID! | ||
_id: String | ||
title: String | ||
date: String | ||
description: String | ||
author: String | ||
} | ||
|
||
type Query { | ||
product(id: ID!): Product | ||
products: [Product] | ||
event(id: ID!): Event | ||
events: [Event] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const graphql = require("graphql"); | ||
const globalIdField = require("graphql-relay").globalIdField; | ||
|
||
const { GraphQLObjectType, GraphQLString } = graphql; | ||
|
||
const EventType = new GraphQLObjectType({ | ||
name: "Event", | ||
fields: () => ({ | ||
id: globalIdField("events"), | ||
_id: { type: GraphQLString }, | ||
title: { type: GraphQLString }, | ||
date: { type: GraphQLString }, | ||
description: { type: GraphQLString }, | ||
author: { type: GraphQLString } | ||
}) | ||
}); | ||
|
||
module.exports = EventType; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
var mongoose = require("mongoose"); | ||
|
||
const EventSchema = new mongoose.Schema({ | ||
title: String, | ||
date: String, | ||
description: String, | ||
author: String | ||
}); | ||
|
||
module.exports = mongoose.model("Event", EventSchema); |