graphql api tested & user resolver, schema and mongo interfaces tested
This commit is contained in:
49
graphql/schema/personTypeDefs.ts
Normal file
49
graphql/schema/personTypeDefs.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { gql } from "graphql-tag";
|
||||
|
||||
export const personTypeDefs = gql`
|
||||
scalar Date
|
||||
|
||||
type Person {
|
||||
id: ID!
|
||||
firstName: String!
|
||||
surname: String!
|
||||
middleName: String!
|
||||
sexCode: String!
|
||||
personRef: String!
|
||||
personTag: String!
|
||||
fatherName: String!
|
||||
motherName: String!
|
||||
countryCode: String!
|
||||
nationalIdentityId: String!
|
||||
birthPlace: String!
|
||||
birthDate: Date!
|
||||
taxNo: String!
|
||||
birthname: String!
|
||||
}
|
||||
|
||||
input CreatePersonInput {
|
||||
firstName: String!
|
||||
surname: String!
|
||||
middleName: String!
|
||||
sexCode: String!
|
||||
personRef: String!
|
||||
personTag: String!
|
||||
fatherName: String!
|
||||
motherName: String!
|
||||
countryCode: String!
|
||||
nationalIdentityId: String!
|
||||
birthPlace: String!
|
||||
birthDate: Date!
|
||||
taxNo: String!
|
||||
birthname: String!
|
||||
}
|
||||
|
||||
type Query {
|
||||
persons: [Person!]!
|
||||
person(id: ID!): Person
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
createPerson(input: CreatePersonInput!): Person!
|
||||
}
|
||||
`;
|
||||
@@ -1,13 +0,0 @@
|
||||
import { gql } from "graphql-tag";
|
||||
|
||||
export const userTypeDefs = gql`
|
||||
type User {
|
||||
_id: ID!
|
||||
name: String!
|
||||
email: String!
|
||||
}
|
||||
|
||||
type Query {
|
||||
users: [User!]!
|
||||
}
|
||||
`;
|
||||
75
graphql/schema/userTypeDefs.ts
Normal file
75
graphql/schema/userTypeDefs.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import { gql } from "graphql-tag";
|
||||
|
||||
export const userTypeDefs = gql`
|
||||
"""Represents a single token entry with a prefix and value"""
|
||||
type CollectionTokenItem {
|
||||
prefix: String!
|
||||
token: String!
|
||||
}
|
||||
|
||||
"""Represents the collection of tokens assigned to a user"""
|
||||
type CollectionToken {
|
||||
tokens: [CollectionTokenItem!]!
|
||||
default: String!
|
||||
}
|
||||
|
||||
type Person {
|
||||
id: ID!
|
||||
firstName: String!
|
||||
surname: String!
|
||||
middleName: String!
|
||||
}
|
||||
|
||||
"""User model with references and metadata"""
|
||||
type User {
|
||||
id: ID!
|
||||
uuid: String!
|
||||
expiresAt: String
|
||||
resetToken: String
|
||||
password: String!
|
||||
history: [String!]
|
||||
tag: String!
|
||||
email: String!
|
||||
phone: String!
|
||||
collectionTokens: CollectionToken!
|
||||
person: Person!
|
||||
type: ID
|
||||
createdAt: String
|
||||
updatedAt: String
|
||||
}
|
||||
|
||||
"""Input type for a single token entry"""
|
||||
input CollectionTokenItemInput {
|
||||
prefix: String!
|
||||
token: String!
|
||||
}
|
||||
|
||||
"""Input type for a user's token collection"""
|
||||
input CollectionTokenInput {
|
||||
tokens: [CollectionTokenItemInput!]!
|
||||
default: String!
|
||||
}
|
||||
|
||||
"""Input for creating a new user"""
|
||||
input CreateUserInput {
|
||||
password: String!
|
||||
history: [String!]
|
||||
tag: String!
|
||||
email: String!
|
||||
phone: String!
|
||||
collectionTokens: CollectionTokenInput!
|
||||
person: ID!
|
||||
type: ID
|
||||
}
|
||||
|
||||
"""Queries"""
|
||||
type Query {
|
||||
users: [User!]!
|
||||
user(id: ID!): User
|
||||
}
|
||||
|
||||
"""Mutations"""
|
||||
type Mutation {
|
||||
createUser(input: CreateUserInput!): User!
|
||||
}
|
||||
`;
|
||||
Reference in New Issue
Block a user