This file contains hidden or 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
| import mongoose from "mongoose"; | |
| const UserSchema = new mongoose.Schema({ | |
| email: String, | |
| name: String, | |
| picture: String, | |
| given_name: String, | |
| family_name: String, | |
| locale: String | |
| }); |
This file contains hidden or 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
| import { | |
| addMockFunctionsToSchema, | |
| gql, | |
| makeExecutableSchema | |
| } from "apollo-server"; | |
| import { GraphQLSchema } from "graphql"; | |
| const userSchema: GraphQLSchema = makeExecutableSchema({ | |
| typeDefs: gql` | |
| type Query { |
This file contains hidden or 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
| import { userController } from "../controllers/controllers"; | |
| import { AuthenticationError } from "apollo-server"; | |
| const userResolver = { | |
| Query: { | |
| posts(root: any, args: any, context: any) { | |
| return userController.posts(); | |
| }, | |
| users(root: any, args: any, context: any) { | |
| return userController.users(root, args.user); | |
| }, |
This file contains hidden or 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
| import { User, Post } from "../models/users"; | |
| import { client } from "../server"; | |
| import { CLIENT_ID } from "../server"; | |
| const userController = { | |
| users: (root: any, args: any) => User.find({}), | |
| findOrCreateUser: async (token: string) => { | |
| if (!token) { | |
| return {authorized: false}; |
This file contains hidden or 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
| import { ApolloServer, AuthenticationError } from "apollo-server"; | |
| import express from "express"; | |
| import mongoose from "mongoose"; | |
| import { GraphQLSchema } from "graphql"; | |
| import { mergeSchemas } from "graphql-tools"; | |
| const { OAuth2Client } = require("google-auth-library"); | |
| import schemas from "./schemas/schema"; | |
| import resolvers from "./resolvers/resolvers"; | |
| import { userController } from "./controllers/controllers"; |
This file contains hidden or 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
| import { userController } from "../controllers/controllers"; | |
| import { AuthenticationError } from "apollo-server"; | |
| const userResolver = { | |
| Query: { | |
| posts(root: any, args: any, context: any) { | |
| return userController.posts(); | |
| }, | |
| users(root: any, args: any, context: any) { | |
| console.log(context); | |
| if (!context.authorized){ |
This file contains hidden or 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
| import { BrowserModule } from '@angular/platform-browser'; | |
| import { NgModule, Injector } from '@angular/core'; | |
| import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | |
| import { | |
| MatTableModule, | |
| MatPaginatorModule, | |
| MatSortModule, | |
| } from '@angular/material'; | |
| import { createCustomElement } from '@angular/elements'; |
This file contains hidden or 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
| module.exports = { | |
| externals: { | |
| rxjs: 'rxjs', | |
| '@angular/core': 'ng.core', | |
| '@angular/common': 'ng.common', | |
| '@angular/platform-browser': 'ng.platformBrowser', | |
| '@angular/elements': 'ng.elements', | |
| }, | |
| }; |
This file contains hidden or 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
| import { | |
| addMockFunctionsToSchema, | |
| gql, | |
| makeExecutableSchema | |
| } from "apollo-server"; | |
| import { GraphQLSchema } from "graphql"; | |
| const postSchema: GraphQLSchema = makeExecutableSchema({ | |
| typeDefs: gql` | |
| type Query { |
This file contains hidden or 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
| import mongoose from "mongoose"; | |
| const PostSchema = new mongoose.Schema({ | |
| author: String, | |
| comment: String | |
| }); | |
| const Post = mongoose.model("posts", PostSchema); | |
| export { Post }; |