node-validations 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +104 -0
  2. package/package.json +13 -0
package/index.js ADDED
@@ -0,0 +1,104 @@
1
+ // import { ApolloServer, gql } from "apollo-server";
2
+ // import { ApolloServerPluginLandingPageGraphQLPlayground } from "apollo-server-core";
3
+ // import {users} from "./users.js";
4
+ // import { queries } from "./queries.js";
5
+
6
+ // const typeDefs = gql`
7
+ // type User{
8
+ // id : Int,
9
+ // name : String,
10
+ // email : String,
11
+ // city : String,
12
+ // queries : [QueryType]
13
+ // }
14
+ // type QueryType{
15
+ // id:Int,
16
+ // title : String
17
+ // }
18
+
19
+ // type Query{
20
+ // users: [User],
21
+ // user(id:Int) : User,
22
+ // queries:[QueryType],
23
+ // usersByCity(city : String) : [User]
24
+ // countUsers : Int
25
+ // usersWithQueryCount:[UserQueryCount]
26
+ // }
27
+
28
+ // type Mutation{
29
+ // addUser(name:String!, email:String!, city:String!):User
30
+ // addQuery(id:Int!, title:String!):QueryType
31
+ // updateEmail (id:Int!, email:String!) : User
32
+ // deleteUser(id:Int!):String
33
+ // }
34
+
35
+ // type UserQueryCount{
36
+ // name:String
37
+ // totalQueries:Int
38
+ // }
39
+ // `
40
+
41
+ // const resolvers = {
42
+ // Query:{
43
+ // users : ()=>users,
44
+ // user : (_,{id})=>{
45
+ // const user = users.find(ele=>ele.id===id);
46
+ // if(!user) return null;
47
+ // return{
48
+ // ...user,
49
+ // queries : queries.filter(q=>q.id===id)
50
+ // }
51
+ // },
52
+ // queries : ()=>queries,
53
+ // usersByCity : (_,{city})=>{
54
+ // return users.filter(ele=>ele.city === city)
55
+ // },
56
+ // countUsers : ()=>users.length,
57
+ // usersWithQueryCount:()=>{
58
+ // return users.map(user=>({
59
+ // name:user.name,
60
+ // totalQueries: queries.filter(q=>q.id==id).length;
61
+ // }))
62
+ // }
63
+ // },
64
+ // Mutation:{
65
+ // addUser: (_,{name, email, city}) =>{
66
+ // const newUser = {
67
+ // id:users.length + 1,
68
+ // name, email, city
69
+ // }
70
+ // users.push(newUser);
71
+ // return newUser
72
+ // },
73
+ // addQuery:(_,{id, title})=>{
74
+ // const newQuery = {
75
+ // id, title
76
+ // }
77
+ // queries.push(newQuery);
78
+ // return newQuery;
79
+ // },
80
+ // updateEmail :(_, {id, email})=>{
81
+ // const user = users.find(ele=>ele.id===id);
82
+ // if(!user) return null;
83
+ // user.email = email;
84
+ // return user;
85
+ // },
86
+ // deleteUser:(_,{id})=>{
87
+ // const idx = users.findIndex(ele=>ele.id===id);
88
+ // if(idx==-1) return "user not found";
89
+ // users.splice(idx, 1);
90
+ // return "user deleted successfully";
91
+ // }
92
+
93
+ // }
94
+ // }
95
+
96
+ // const server = new ApolloServer({
97
+ // typeDefs,
98
+ // resolvers,
99
+ // plugins:[ApolloServerPluginLandingPageGraphQLPlayground()]
100
+ // })
101
+ // server.listen().then(({url})=>{
102
+ // console.log("Server started...", url)
103
+ // })
104
+
package/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "node-validations",
3
+ "version": "1.0.2",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords": [],
10
+ "author": "",
11
+ "license": "ISC",
12
+ "type": "commonjs"
13
+ }