Scope server with workspace (#157)

* Rename User to AuthUser to avoid naming conflict with user business entity

* Prevent query by workspace in graphql

* Make full user and workspace object available in graphql resolvers

* Add Seed to create companies and people accross two workspace

* Check workspace on all entities findMany, find, create, update)
This commit is contained in:
Charles Bochet
2023-05-30 20:40:04 +02:00
committed by GitHub
parent 0f9c6dede7
commit 3674365e6f
47 changed files with 380 additions and 483 deletions

View File

@ -67,30 +67,6 @@ export type CompanyCreateInput = {
updatedAt?: InputMaybe<Scalars['DateTime']>;
};
export type CompanyCreateManyWorkspaceInput = {
accountOwnerId?: InputMaybe<Scalars['String']>;
address: Scalars['String'];
createdAt?: InputMaybe<Scalars['DateTime']>;
deletedAt?: InputMaybe<Scalars['DateTime']>;
domainName: Scalars['String'];
employees?: InputMaybe<Scalars['Int']>;
id: Scalars['String'];
name: Scalars['String'];
updatedAt?: InputMaybe<Scalars['DateTime']>;
};
export type CompanyCreateManyWorkspaceInputEnvelope = {
data: Array<CompanyCreateManyWorkspaceInput>;
skipDuplicates?: InputMaybe<Scalars['Boolean']>;
};
export type CompanyCreateNestedManyWithoutWorkspaceInput = {
connect?: InputMaybe<Array<CompanyWhereUniqueInput>>;
connectOrCreate?: InputMaybe<Array<CompanyCreateOrConnectWithoutWorkspaceInput>>;
create?: InputMaybe<Array<CompanyCreateWithoutWorkspaceInput>>;
createMany?: InputMaybe<CompanyCreateManyWorkspaceInputEnvelope>;
};
export type CompanyCreateNestedOneWithoutPeopleInput = {
connect?: InputMaybe<CompanyWhereUniqueInput>;
connectOrCreate?: InputMaybe<CompanyCreateOrConnectWithoutPeopleInput>;
@ -102,11 +78,6 @@ export type CompanyCreateOrConnectWithoutPeopleInput = {
where: CompanyWhereUniqueInput;
};
export type CompanyCreateOrConnectWithoutWorkspaceInput = {
create: CompanyCreateWithoutWorkspaceInput;
where: CompanyWhereUniqueInput;
};
export type CompanyCreateWithoutPeopleInput = {
accountOwner?: InputMaybe<UserCreateNestedOneWithoutCompaniesInput>;
address: Scalars['String'];
@ -119,19 +90,6 @@ export type CompanyCreateWithoutPeopleInput = {
updatedAt?: InputMaybe<Scalars['DateTime']>;
};
export type CompanyCreateWithoutWorkspaceInput = {
accountOwner?: InputMaybe<UserCreateNestedOneWithoutCompaniesInput>;
address: Scalars['String'];
createdAt?: InputMaybe<Scalars['DateTime']>;
deletedAt?: InputMaybe<Scalars['DateTime']>;
domainName: Scalars['String'];
employees?: InputMaybe<Scalars['Int']>;
id: Scalars['String'];
name: Scalars['String'];
people?: InputMaybe<PersonCreateNestedManyWithoutCompanyInput>;
updatedAt?: InputMaybe<Scalars['DateTime']>;
};
export type CompanyListRelationFilter = {
every?: InputMaybe<CompanyWhereInput>;
none?: InputMaybe<CompanyWhereInput>;
@ -174,21 +132,6 @@ export enum CompanyScalarFieldEnum {
WorkspaceId = 'workspaceId'
}
export type CompanyScalarWhereInput = {
AND?: InputMaybe<Array<CompanyScalarWhereInput>>;
NOT?: InputMaybe<Array<CompanyScalarWhereInput>>;
OR?: InputMaybe<Array<CompanyScalarWhereInput>>;
accountOwnerId?: InputMaybe<StringNullableFilter>;
address?: InputMaybe<StringFilter>;
createdAt?: InputMaybe<DateTimeFilter>;
deletedAt?: InputMaybe<DateTimeNullableFilter>;
domainName?: InputMaybe<StringFilter>;
employees?: InputMaybe<IntNullableFilter>;
id?: InputMaybe<StringFilter>;
name?: InputMaybe<StringFilter>;
updatedAt?: InputMaybe<DateTimeFilter>;
};
export type CompanyUpdateInput = {
accountOwner?: InputMaybe<UserUpdateOneWithoutCompaniesNestedInput>;
address?: InputMaybe<StringFieldUpdateOperationsInput>;
@ -202,36 +145,6 @@ export type CompanyUpdateInput = {
updatedAt?: InputMaybe<DateTimeFieldUpdateOperationsInput>;
};
export type CompanyUpdateManyMutationInput = {
address?: InputMaybe<StringFieldUpdateOperationsInput>;
createdAt?: InputMaybe<DateTimeFieldUpdateOperationsInput>;
deletedAt?: InputMaybe<NullableDateTimeFieldUpdateOperationsInput>;
domainName?: InputMaybe<StringFieldUpdateOperationsInput>;
employees?: InputMaybe<NullableIntFieldUpdateOperationsInput>;
id?: InputMaybe<StringFieldUpdateOperationsInput>;
name?: InputMaybe<StringFieldUpdateOperationsInput>;
updatedAt?: InputMaybe<DateTimeFieldUpdateOperationsInput>;
};
export type CompanyUpdateManyWithWhereWithoutWorkspaceInput = {
data: CompanyUpdateManyMutationInput;
where: CompanyScalarWhereInput;
};
export type CompanyUpdateManyWithoutWorkspaceNestedInput = {
connect?: InputMaybe<Array<CompanyWhereUniqueInput>>;
connectOrCreate?: InputMaybe<Array<CompanyCreateOrConnectWithoutWorkspaceInput>>;
create?: InputMaybe<Array<CompanyCreateWithoutWorkspaceInput>>;
createMany?: InputMaybe<CompanyCreateManyWorkspaceInputEnvelope>;
delete?: InputMaybe<Array<CompanyWhereUniqueInput>>;
deleteMany?: InputMaybe<Array<CompanyScalarWhereInput>>;
disconnect?: InputMaybe<Array<CompanyWhereUniqueInput>>;
set?: InputMaybe<Array<CompanyWhereUniqueInput>>;
update?: InputMaybe<Array<CompanyUpdateWithWhereUniqueWithoutWorkspaceInput>>;
updateMany?: InputMaybe<Array<CompanyUpdateManyWithWhereWithoutWorkspaceInput>>;
upsert?: InputMaybe<Array<CompanyUpsertWithWhereUniqueWithoutWorkspaceInput>>;
};
export type CompanyUpdateOneWithoutPeopleNestedInput = {
connect?: InputMaybe<CompanyWhereUniqueInput>;
connectOrCreate?: InputMaybe<CompanyCreateOrConnectWithoutPeopleInput>;
@ -242,11 +155,6 @@ export type CompanyUpdateOneWithoutPeopleNestedInput = {
upsert?: InputMaybe<CompanyUpsertWithoutPeopleInput>;
};
export type CompanyUpdateWithWhereUniqueWithoutWorkspaceInput = {
data: CompanyUpdateWithoutWorkspaceInput;
where: CompanyWhereUniqueInput;
};
export type CompanyUpdateWithoutPeopleInput = {
accountOwner?: InputMaybe<UserUpdateOneWithoutCompaniesNestedInput>;
address?: InputMaybe<StringFieldUpdateOperationsInput>;
@ -259,25 +167,6 @@ export type CompanyUpdateWithoutPeopleInput = {
updatedAt?: InputMaybe<DateTimeFieldUpdateOperationsInput>;
};
export type CompanyUpdateWithoutWorkspaceInput = {
accountOwner?: InputMaybe<UserUpdateOneWithoutCompaniesNestedInput>;
address?: InputMaybe<StringFieldUpdateOperationsInput>;
createdAt?: InputMaybe<DateTimeFieldUpdateOperationsInput>;
deletedAt?: InputMaybe<NullableDateTimeFieldUpdateOperationsInput>;
domainName?: InputMaybe<StringFieldUpdateOperationsInput>;
employees?: InputMaybe<NullableIntFieldUpdateOperationsInput>;
id?: InputMaybe<StringFieldUpdateOperationsInput>;
name?: InputMaybe<StringFieldUpdateOperationsInput>;
people?: InputMaybe<PersonUpdateManyWithoutCompanyNestedInput>;
updatedAt?: InputMaybe<DateTimeFieldUpdateOperationsInput>;
};
export type CompanyUpsertWithWhereUniqueWithoutWorkspaceInput = {
create: CompanyCreateWithoutWorkspaceInput;
update: CompanyUpdateWithoutWorkspaceInput;
where: CompanyWhereUniqueInput;
};
export type CompanyUpsertWithoutPeopleInput = {
create: CompanyCreateWithoutPeopleInput;
update: CompanyUpdateWithoutPeopleInput;
@ -363,7 +252,6 @@ export type Mutation = {
createOnePerson: Person;
deleteManyCompany: AffectedRows;
deleteManyPerson: AffectedRows;
deleteOneCompany?: Maybe<Company>;
updateOneCompany?: Maybe<Company>;
updateOnePerson?: Maybe<Person>;
};
@ -389,11 +277,6 @@ export type MutationDeleteManyPersonArgs = {
};
export type MutationDeleteOneCompanyArgs = {
where: CompanyWhereUniqueInput;
};
export type MutationUpdateOneCompanyArgs = {
data: CompanyUpdateInput;
where: CompanyWhereUniqueInput;
@ -534,24 +417,6 @@ export type PersonCreateManyCompanyInputEnvelope = {
skipDuplicates?: InputMaybe<Scalars['Boolean']>;
};
export type PersonCreateManyWorkspaceInput = {
city: Scalars['String'];
companyId?: InputMaybe<Scalars['String']>;
createdAt?: InputMaybe<Scalars['DateTime']>;
deletedAt?: InputMaybe<Scalars['DateTime']>;
email: Scalars['String'];
firstname: Scalars['String'];
id: Scalars['String'];
lastname: Scalars['String'];
phone: Scalars['String'];
updatedAt?: InputMaybe<Scalars['DateTime']>;
};
export type PersonCreateManyWorkspaceInputEnvelope = {
data: Array<PersonCreateManyWorkspaceInput>;
skipDuplicates?: InputMaybe<Scalars['Boolean']>;
};
export type PersonCreateNestedManyWithoutCompanyInput = {
connect?: InputMaybe<Array<PersonWhereUniqueInput>>;
connectOrCreate?: InputMaybe<Array<PersonCreateOrConnectWithoutCompanyInput>>;
@ -559,23 +424,11 @@ export type PersonCreateNestedManyWithoutCompanyInput = {
createMany?: InputMaybe<PersonCreateManyCompanyInputEnvelope>;
};
export type PersonCreateNestedManyWithoutWorkspaceInput = {
connect?: InputMaybe<Array<PersonWhereUniqueInput>>;
connectOrCreate?: InputMaybe<Array<PersonCreateOrConnectWithoutWorkspaceInput>>;
create?: InputMaybe<Array<PersonCreateWithoutWorkspaceInput>>;
createMany?: InputMaybe<PersonCreateManyWorkspaceInputEnvelope>;
};
export type PersonCreateOrConnectWithoutCompanyInput = {
create: PersonCreateWithoutCompanyInput;
where: PersonWhereUniqueInput;
};
export type PersonCreateOrConnectWithoutWorkspaceInput = {
create: PersonCreateWithoutWorkspaceInput;
where: PersonWhereUniqueInput;
};
export type PersonCreateWithoutCompanyInput = {
city: Scalars['String'];
createdAt?: InputMaybe<Scalars['DateTime']>;
@ -588,19 +441,6 @@ export type PersonCreateWithoutCompanyInput = {
updatedAt?: InputMaybe<Scalars['DateTime']>;
};
export type PersonCreateWithoutWorkspaceInput = {
city: Scalars['String'];
company?: InputMaybe<CompanyCreateNestedOneWithoutPeopleInput>;
createdAt?: InputMaybe<Scalars['DateTime']>;
deletedAt?: InputMaybe<Scalars['DateTime']>;
email: Scalars['String'];
firstname: Scalars['String'];
id: Scalars['String'];
lastname: Scalars['String'];
phone: Scalars['String'];
updatedAt?: InputMaybe<Scalars['DateTime']>;
};
export type PersonListRelationFilter = {
every?: InputMaybe<PersonWhereInput>;
none?: InputMaybe<PersonWhereInput>;
@ -685,11 +525,6 @@ export type PersonUpdateManyWithWhereWithoutCompanyInput = {
where: PersonScalarWhereInput;
};
export type PersonUpdateManyWithWhereWithoutWorkspaceInput = {
data: PersonUpdateManyMutationInput;
where: PersonScalarWhereInput;
};
export type PersonUpdateManyWithoutCompanyNestedInput = {
connect?: InputMaybe<Array<PersonWhereUniqueInput>>;
connectOrCreate?: InputMaybe<Array<PersonCreateOrConnectWithoutCompanyInput>>;
@ -704,30 +539,11 @@ export type PersonUpdateManyWithoutCompanyNestedInput = {
upsert?: InputMaybe<Array<PersonUpsertWithWhereUniqueWithoutCompanyInput>>;
};
export type PersonUpdateManyWithoutWorkspaceNestedInput = {
connect?: InputMaybe<Array<PersonWhereUniqueInput>>;
connectOrCreate?: InputMaybe<Array<PersonCreateOrConnectWithoutWorkspaceInput>>;
create?: InputMaybe<Array<PersonCreateWithoutWorkspaceInput>>;
createMany?: InputMaybe<PersonCreateManyWorkspaceInputEnvelope>;
delete?: InputMaybe<Array<PersonWhereUniqueInput>>;
deleteMany?: InputMaybe<Array<PersonScalarWhereInput>>;
disconnect?: InputMaybe<Array<PersonWhereUniqueInput>>;
set?: InputMaybe<Array<PersonWhereUniqueInput>>;
update?: InputMaybe<Array<PersonUpdateWithWhereUniqueWithoutWorkspaceInput>>;
updateMany?: InputMaybe<Array<PersonUpdateManyWithWhereWithoutWorkspaceInput>>;
upsert?: InputMaybe<Array<PersonUpsertWithWhereUniqueWithoutWorkspaceInput>>;
};
export type PersonUpdateWithWhereUniqueWithoutCompanyInput = {
data: PersonUpdateWithoutCompanyInput;
where: PersonWhereUniqueInput;
};
export type PersonUpdateWithWhereUniqueWithoutWorkspaceInput = {
data: PersonUpdateWithoutWorkspaceInput;
where: PersonWhereUniqueInput;
};
export type PersonUpdateWithoutCompanyInput = {
city?: InputMaybe<StringFieldUpdateOperationsInput>;
createdAt?: InputMaybe<DateTimeFieldUpdateOperationsInput>;
@ -740,31 +556,12 @@ export type PersonUpdateWithoutCompanyInput = {
updatedAt?: InputMaybe<DateTimeFieldUpdateOperationsInput>;
};
export type PersonUpdateWithoutWorkspaceInput = {
city?: InputMaybe<StringFieldUpdateOperationsInput>;
company?: InputMaybe<CompanyUpdateOneWithoutPeopleNestedInput>;
createdAt?: InputMaybe<DateTimeFieldUpdateOperationsInput>;
deletedAt?: InputMaybe<NullableDateTimeFieldUpdateOperationsInput>;
email?: InputMaybe<StringFieldUpdateOperationsInput>;
firstname?: InputMaybe<StringFieldUpdateOperationsInput>;
id?: InputMaybe<StringFieldUpdateOperationsInput>;
lastname?: InputMaybe<StringFieldUpdateOperationsInput>;
phone?: InputMaybe<StringFieldUpdateOperationsInput>;
updatedAt?: InputMaybe<DateTimeFieldUpdateOperationsInput>;
};
export type PersonUpsertWithWhereUniqueWithoutCompanyInput = {
create: PersonCreateWithoutCompanyInput;
update: PersonUpdateWithoutCompanyInput;
where: PersonWhereUniqueInput;
};
export type PersonUpsertWithWhereUniqueWithoutWorkspaceInput = {
create: PersonCreateWithoutWorkspaceInput;
update: PersonUpdateWithoutWorkspaceInput;
where: PersonWhereUniqueInput;
};
export type PersonWhereInput = {
AND?: InputMaybe<Array<PersonWhereInput>>;
NOT?: InputMaybe<Array<PersonWhereInput>>;
@ -788,14 +585,13 @@ export type PersonWhereUniqueInput = {
export type Query = {
__typename?: 'Query';
companies: Array<Company>;
people: Array<Person>;
user: User;
users: Array<User>;
findManyCompany: Array<Company>;
findManyPerson: Array<Person>;
findManyUser: Array<User>;
};
export type QueryCompaniesArgs = {
export type QueryFindManyCompanyArgs = {
cursor?: InputMaybe<CompanyWhereUniqueInput>;
distinct?: InputMaybe<Array<CompanyScalarFieldEnum>>;
orderBy?: InputMaybe<Array<CompanyOrderByWithRelationInput>>;
@ -805,7 +601,7 @@ export type QueryCompaniesArgs = {
};
export type QueryPeopleArgs = {
export type QueryFindManyPersonArgs = {
cursor?: InputMaybe<PersonWhereUniqueInput>;
distinct?: InputMaybe<Array<PersonScalarFieldEnum>>;
orderBy?: InputMaybe<Array<PersonOrderByWithRelationInput>>;
@ -815,12 +611,7 @@ export type QueryPeopleArgs = {
};
export type QueryUserArgs = {
where: UserWhereUniqueInput;
};
export type QueryUsersArgs = {
export type QueryFindManyUserArgs = {
cursor?: InputMaybe<UserWhereUniqueInput>;
distinct?: InputMaybe<Array<UserScalarFieldEnum>>;
orderBy?: InputMaybe<Array<UserOrderByWithRelationInput>>;
@ -1225,29 +1016,6 @@ export type WorkspaceCount = {
people: Scalars['Int'];
};
export type WorkspaceCreateNestedOneWithoutWorkspaceMemberInput = {
connect?: InputMaybe<WorkspaceWhereUniqueInput>;
connectOrCreate?: InputMaybe<WorkspaceCreateOrConnectWithoutWorkspaceMemberInput>;
create?: InputMaybe<WorkspaceCreateWithoutWorkspaceMemberInput>;
};
export type WorkspaceCreateOrConnectWithoutWorkspaceMemberInput = {
create: WorkspaceCreateWithoutWorkspaceMemberInput;
where: WorkspaceWhereUniqueInput;
};
export type WorkspaceCreateWithoutWorkspaceMemberInput = {
companies?: InputMaybe<CompanyCreateNestedManyWithoutWorkspaceInput>;
createdAt?: InputMaybe<Scalars['DateTime']>;
deletedAt?: InputMaybe<Scalars['DateTime']>;
displayName: Scalars['String'];
domainName: Scalars['String'];
id: Scalars['String'];
logo?: InputMaybe<Scalars['String']>;
people?: InputMaybe<PersonCreateNestedManyWithoutWorkspaceInput>;
updatedAt?: InputMaybe<Scalars['DateTime']>;
};
export type WorkspaceMember = {
__typename?: 'WorkspaceMember';
createdAt: Scalars['DateTime'];
@ -1276,17 +1044,6 @@ export type WorkspaceMemberCreateWithoutUserInput = {
deletedAt?: InputMaybe<Scalars['DateTime']>;
id: Scalars['String'];
updatedAt?: InputMaybe<Scalars['DateTime']>;
workspace: WorkspaceCreateNestedOneWithoutWorkspaceMemberInput;
};
export type WorkspaceMemberListRelationFilter = {
every?: InputMaybe<WorkspaceMemberWhereInput>;
none?: InputMaybe<WorkspaceMemberWhereInput>;
some?: InputMaybe<WorkspaceMemberWhereInput>;
};
export type WorkspaceMemberOrderByRelationAggregateInput = {
_count?: InputMaybe<SortOrder>;
};
export type WorkspaceMemberOrderByWithRelationInput = {
@ -1296,8 +1053,6 @@ export type WorkspaceMemberOrderByWithRelationInput = {
updatedAt?: InputMaybe<SortOrder>;
user?: InputMaybe<UserOrderByWithRelationInput>;
userId?: InputMaybe<SortOrder>;
workspace?: InputMaybe<WorkspaceOrderByWithRelationInput>;
workspaceId?: InputMaybe<SortOrder>;
};
export type WorkspaceMemberRelationFilter = {
@ -1320,7 +1075,6 @@ export type WorkspaceMemberUpdateWithoutUserInput = {
deletedAt?: InputMaybe<NullableDateTimeFieldUpdateOperationsInput>;
id?: InputMaybe<StringFieldUpdateOperationsInput>;
updatedAt?: InputMaybe<DateTimeFieldUpdateOperationsInput>;
workspace?: InputMaybe<WorkspaceUpdateOneRequiredWithoutWorkspaceMemberNestedInput>;
};
export type WorkspaceMemberUpsertWithoutUserInput = {
@ -1338,8 +1092,6 @@ export type WorkspaceMemberWhereInput = {
updatedAt?: InputMaybe<DateTimeFilter>;
user?: InputMaybe<UserRelationFilter>;
userId?: InputMaybe<StringFilter>;
workspace?: InputMaybe<WorkspaceRelationFilter>;
workspaceId?: InputMaybe<StringFilter>;
};
export type WorkspaceMemberWhereUniqueInput = {
@ -1347,77 +1099,13 @@ export type WorkspaceMemberWhereUniqueInput = {
userId?: InputMaybe<Scalars['String']>;
};
export type WorkspaceOrderByWithRelationInput = {
WorkspaceMember?: InputMaybe<WorkspaceMemberOrderByRelationAggregateInput>;
companies?: InputMaybe<CompanyOrderByRelationAggregateInput>;
createdAt?: InputMaybe<SortOrder>;
deletedAt?: InputMaybe<SortOrder>;
displayName?: InputMaybe<SortOrder>;
domainName?: InputMaybe<SortOrder>;
id?: InputMaybe<SortOrder>;
logo?: InputMaybe<SortOrder>;
people?: InputMaybe<PersonOrderByRelationAggregateInput>;
updatedAt?: InputMaybe<SortOrder>;
};
export type WorkspaceRelationFilter = {
is?: InputMaybe<WorkspaceWhereInput>;
isNot?: InputMaybe<WorkspaceWhereInput>;
};
export type WorkspaceUpdateOneRequiredWithoutWorkspaceMemberNestedInput = {
connect?: InputMaybe<WorkspaceWhereUniqueInput>;
connectOrCreate?: InputMaybe<WorkspaceCreateOrConnectWithoutWorkspaceMemberInput>;
create?: InputMaybe<WorkspaceCreateWithoutWorkspaceMemberInput>;
update?: InputMaybe<WorkspaceUpdateWithoutWorkspaceMemberInput>;
upsert?: InputMaybe<WorkspaceUpsertWithoutWorkspaceMemberInput>;
};
export type WorkspaceUpdateWithoutWorkspaceMemberInput = {
companies?: InputMaybe<CompanyUpdateManyWithoutWorkspaceNestedInput>;
createdAt?: InputMaybe<DateTimeFieldUpdateOperationsInput>;
deletedAt?: InputMaybe<NullableDateTimeFieldUpdateOperationsInput>;
displayName?: InputMaybe<StringFieldUpdateOperationsInput>;
domainName?: InputMaybe<StringFieldUpdateOperationsInput>;
id?: InputMaybe<StringFieldUpdateOperationsInput>;
logo?: InputMaybe<NullableStringFieldUpdateOperationsInput>;
people?: InputMaybe<PersonUpdateManyWithoutWorkspaceNestedInput>;
updatedAt?: InputMaybe<DateTimeFieldUpdateOperationsInput>;
};
export type WorkspaceUpsertWithoutWorkspaceMemberInput = {
create: WorkspaceCreateWithoutWorkspaceMemberInput;
update: WorkspaceUpdateWithoutWorkspaceMemberInput;
};
export type WorkspaceWhereInput = {
AND?: InputMaybe<Array<WorkspaceWhereInput>>;
NOT?: InputMaybe<Array<WorkspaceWhereInput>>;
OR?: InputMaybe<Array<WorkspaceWhereInput>>;
WorkspaceMember?: InputMaybe<WorkspaceMemberListRelationFilter>;
companies?: InputMaybe<CompanyListRelationFilter>;
createdAt?: InputMaybe<DateTimeFilter>;
deletedAt?: InputMaybe<DateTimeNullableFilter>;
displayName?: InputMaybe<StringFilter>;
domainName?: InputMaybe<StringFilter>;
id?: InputMaybe<StringFilter>;
logo?: InputMaybe<StringNullableFilter>;
people?: InputMaybe<PersonListRelationFilter>;
updatedAt?: InputMaybe<DateTimeFilter>;
};
export type WorkspaceWhereUniqueInput = {
domainName?: InputMaybe<Scalars['String']>;
id?: InputMaybe<Scalars['String']>;
};
export type GetCompaniesQueryVariables = Exact<{
orderBy?: InputMaybe<Array<CompanyOrderByWithRelationInput> | CompanyOrderByWithRelationInput>;
where?: InputMaybe<CompanyWhereInput>;
}>;
export type GetCompaniesQuery = { __typename?: 'Query', companies: Array<{ __typename?: 'Company', id: string, domainName: string, name: string, createdAt: any, address: string, employees?: number | null, accountOwner?: { __typename?: 'User', id: string, email: string, displayName: string } | null }> };
export type GetCompaniesQuery = { __typename?: 'Query', findManyCompany: Array<{ __typename?: 'Company', id: string, domainName: string, name: string, createdAt: any, address: string, employees?: number | null, accountOwner?: { __typename?: 'User', id: string, email: string, displayName: string } | null }> };
export type UpdateCompanyMutationVariables = Exact<{
id?: InputMaybe<Scalars['String']>;
@ -1458,7 +1146,7 @@ export type GetPeopleQueryVariables = Exact<{
}>;
export type GetPeopleQuery = { __typename?: 'Query', people: Array<{ __typename?: 'Person', id: string, phone: string, email: string, city: string, firstname: string, lastname: string, createdAt: any, company?: { __typename?: 'Company', id: string, name: string, domainName: string } | null }> };
export type GetPeopleQuery = { __typename?: 'Query', findManyPerson: Array<{ __typename?: 'Person', id: string, phone: string, email: string, city: string, firstname: string, lastname: string, createdAt: any, company?: { __typename?: 'Company', id: string, name: string, domainName: string } | null }> };
export type UpdatePeopleMutationVariables = Exact<{
id?: InputMaybe<Scalars['String']>;
@ -1513,39 +1201,39 @@ export type SearchUserQueryQuery = { __typename?: 'Query', searchResults: Array<
export type EmptyQueryQueryVariables = Exact<{ [key: string]: never; }>;
export type EmptyQueryQuery = { __typename?: 'Query', users: Array<{ __typename?: 'User', id: string }> };
export type EmptyQueryQuery = { __typename?: 'Query', findManyUser: Array<{ __typename?: 'User', id: string }> };
export type SearchQueryQueryVariables = Exact<{
export type SearchCompanyQueryQueryVariables = Exact<{
where?: InputMaybe<CompanyWhereInput>;
limit?: InputMaybe<Scalars['Int']>;
}>;
export type SearchQueryQuery = { __typename?: 'Query', searchResults: Array<{ __typename?: 'Company', id: string, name: string, domainName: string }> };
export type SearchCompanyQueryQuery = { __typename?: 'Query', searchResults: Array<{ __typename?: 'Company', id: string, name: string, domainName: string }> };
export type GetCurrentUserQueryVariables = Exact<{
uuid?: InputMaybe<Scalars['String']>;
}>;
export type GetCurrentUserQuery = { __typename?: 'Query', users: Array<{ __typename?: 'User', id: string, email: string, displayName: string, workspaceMember?: { __typename?: 'WorkspaceMember', workspace: { __typename?: 'Workspace', id: string, domainName: string, displayName: string, logo?: string | null } } | null }> };
export type GetCurrentUserQuery = { __typename?: 'Query', findManyUser: Array<{ __typename?: 'User', id: string, email: string, displayName: string, workspaceMember?: { __typename?: 'WorkspaceMember', workspace: { __typename?: 'Workspace', id: string, domainName: string, displayName: string, logo?: string | null } } | null }> };
export type GetUsersQueryVariables = Exact<{ [key: string]: never; }>;
export type GetUsersQuery = { __typename?: 'Query', users: Array<{ __typename?: 'User', id: string }> };
export type GetUsersQuery = { __typename?: 'Query', findManyUser: Array<{ __typename?: 'User', id: string }> };
export const GetCompaniesDocument = gql`
query GetCompanies($orderBy: [CompanyOrderByWithRelationInput!], $where: CompanyWhereInput) {
companies(orderBy: $orderBy, where: $where) {
findManyCompany(orderBy: $orderBy, where: $where) {
id
domainName
name
createdAt
address
employees
accountOwner: accountOwner {
accountOwner {
id
email
displayName
@ -1714,7 +1402,7 @@ export type DeleteCompaniesMutationResult = Apollo.MutationResult<DeleteCompanie
export type DeleteCompaniesMutationOptions = Apollo.BaseMutationOptions<DeleteCompaniesMutation, DeleteCompaniesMutationVariables>;
export const GetPeopleDocument = gql`
query GetPeople($orderBy: [PersonOrderByWithRelationInput!], $where: PersonWhereInput, $limit: Int) {
people(orderBy: $orderBy, where: $where, take: $limit) {
findManyPerson(orderBy: $orderBy, where: $where, take: $limit) {
id
phone
email
@ -1901,7 +1589,7 @@ export type DeletePeopleMutationResult = Apollo.MutationResult<DeletePeopleMutat
export type DeletePeopleMutationOptions = Apollo.BaseMutationOptions<DeletePeopleMutation, DeletePeopleMutationVariables>;
export const SearchPeopleQueryDocument = gql`
query SearchPeopleQuery($where: PersonWhereInput, $limit: Int) {
searchResults: people(where: $where, take: $limit) {
searchResults: findManyPerson(where: $where, take: $limit) {
id
phone
email
@ -1943,7 +1631,7 @@ export type SearchPeopleQueryLazyQueryHookResult = ReturnType<typeof useSearchPe
export type SearchPeopleQueryQueryResult = Apollo.QueryResult<SearchPeopleQueryQuery, SearchPeopleQueryQueryVariables>;
export const SearchUserQueryDocument = gql`
query SearchUserQuery($where: UserWhereInput, $limit: Int) {
searchResults: users(where: $where, take: $limit) {
searchResults: findManyUser(where: $where, take: $limit) {
id
email
displayName
@ -1981,7 +1669,7 @@ export type SearchUserQueryLazyQueryHookResult = ReturnType<typeof useSearchUser
export type SearchUserQueryQueryResult = Apollo.QueryResult<SearchUserQueryQuery, SearchUserQueryQueryVariables>;
export const EmptyQueryDocument = gql`
query EmptyQuery {
users {
findManyUser {
id
}
}
@ -2013,47 +1701,47 @@ export function useEmptyQueryLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions
export type EmptyQueryQueryHookResult = ReturnType<typeof useEmptyQueryQuery>;
export type EmptyQueryLazyQueryHookResult = ReturnType<typeof useEmptyQueryLazyQuery>;
export type EmptyQueryQueryResult = Apollo.QueryResult<EmptyQueryQuery, EmptyQueryQueryVariables>;
export const SearchQueryDocument = gql`
query SearchQuery($where: CompanyWhereInput, $limit: Int) {
searchResults: companies(where: $where, take: $limit) {
export const SearchCompanyQueryDocument = gql`
query SearchCompanyQuery($where: CompanyWhereInput, $limit: Int) {
searchResults: findManyCompany(where: $where, take: $limit) {
id
name
domainName: domainName
domainName
}
}
`;
/**
* __useSearchQueryQuery__
* __useSearchCompanyQueryQuery__
*
* To run a query within a React component, call `useSearchQueryQuery` and pass it any options that fit your needs.
* When your component renders, `useSearchQueryQuery` returns an object from Apollo Client that contains loading, error, and data properties
* To run a query within a React component, call `useSearchCompanyQueryQuery` and pass it any options that fit your needs.
* When your component renders, `useSearchCompanyQueryQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useSearchQueryQuery({
* const { data, loading, error } = useSearchCompanyQueryQuery({
* variables: {
* where: // value for 'where'
* limit: // value for 'limit'
* },
* });
*/
export function useSearchQueryQuery(baseOptions?: Apollo.QueryHookOptions<SearchQueryQuery, SearchQueryQueryVariables>) {
export function useSearchCompanyQueryQuery(baseOptions?: Apollo.QueryHookOptions<SearchCompanyQueryQuery, SearchCompanyQueryQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<SearchQueryQuery, SearchQueryQueryVariables>(SearchQueryDocument, options);
return Apollo.useQuery<SearchCompanyQueryQuery, SearchCompanyQueryQueryVariables>(SearchCompanyQueryDocument, options);
}
export function useSearchQueryLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<SearchQueryQuery, SearchQueryQueryVariables>) {
export function useSearchCompanyQueryLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<SearchCompanyQueryQuery, SearchCompanyQueryQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<SearchQueryQuery, SearchQueryQueryVariables>(SearchQueryDocument, options);
return Apollo.useLazyQuery<SearchCompanyQueryQuery, SearchCompanyQueryQueryVariables>(SearchCompanyQueryDocument, options);
}
export type SearchQueryQueryHookResult = ReturnType<typeof useSearchQueryQuery>;
export type SearchQueryLazyQueryHookResult = ReturnType<typeof useSearchQueryLazyQuery>;
export type SearchQueryQueryResult = Apollo.QueryResult<SearchQueryQuery, SearchQueryQueryVariables>;
export type SearchCompanyQueryQueryHookResult = ReturnType<typeof useSearchCompanyQueryQuery>;
export type SearchCompanyQueryLazyQueryHookResult = ReturnType<typeof useSearchCompanyQueryLazyQuery>;
export type SearchCompanyQueryQueryResult = Apollo.QueryResult<SearchCompanyQueryQuery, SearchCompanyQueryQueryVariables>;
export const GetCurrentUserDocument = gql`
query getCurrentUser($uuid: String) {
users(where: {id: {equals: $uuid}}) {
findManyUser(where: {id: {equals: $uuid}}) {
id
email
displayName
@ -2098,7 +1786,7 @@ export type GetCurrentUserLazyQueryHookResult = ReturnType<typeof useGetCurrentU
export type GetCurrentUserQueryResult = Apollo.QueryResult<GetCurrentUserQuery, GetCurrentUserQueryVariables>;
export const GetUsersDocument = gql`
query getUsers {
users {
findManyUser {
id
}
}

View File

@ -14,7 +14,7 @@ export const GET_COMPANIES = gql`
$orderBy: [CompanyOrderByWithRelationInput!]
$where: CompanyWhereInput
) {
companies(orderBy: $orderBy, where: $where) {
companies: findManyCompany(orderBy: $orderBy, where: $where) {
id
domainName
name

View File

@ -15,7 +15,7 @@ export const GET_PEOPLE = gql`
$where: PersonWhereInput
$limit: Int
) {
people(orderBy: $orderBy, where: $where, take: $limit) {
people: findManyPerson(orderBy: $orderBy, where: $where, take: $limit) {
id
phone
email

View File

@ -9,7 +9,7 @@ import { debounce } from '../../../modules/utils/debounce';
export const SEARCH_PEOPLE_QUERY = gql`
query SearchPeopleQuery($where: PersonWhereInput, $limit: Int) {
searchResults: people(where: $where, take: $limit) {
searchResults: findManyPerson(where: $where, take: $limit) {
id
phone
email
@ -23,7 +23,7 @@ export const SEARCH_PEOPLE_QUERY = gql`
export const SEARCH_USER_QUERY = gql`
query SearchUserQuery($where: UserWhereInput, $limit: Int) {
searchResults: users(where: $where, take: $limit) {
searchResults: findManyUser(where: $where, take: $limit) {
id
email
displayName
@ -33,7 +33,7 @@ export const SEARCH_USER_QUERY = gql`
// TODO: remove this query
export const EMPTY_QUERY = gql`
query EmptyQuery {
users {
searchResults: findManyUser {
id
}
}
@ -41,7 +41,7 @@ export const EMPTY_QUERY = gql`
export const SEARCH_COMPANY_QUERY = gql`
query SearchCompanyQuery($where: CompanyWhereInput, $limit: Int) {
searchResults: companies(where: $where, take: $limit) {
searchResults: findManyCompany(where: $where, take: $limit) {
id
name
domainName

View File

@ -3,7 +3,7 @@ import { GraphqlQueryUser } from '../../../interfaces/entities/user.interface';
export const GET_CURRENT_USER = gql`
query getCurrentUser($uuid: String) {
users(where: { id: { equals: $uuid } }) {
users: findManyUser(where: { id: { equals: $uuid } }) {
id
email
displayName

View File

@ -2,7 +2,7 @@ import { gql } from '@apollo/client';
export const GET_CURRENT_USER = gql`
query getUsers {
users {
findManyUser {
id
}
}

View File

@ -74,7 +74,6 @@ export function filterAndSortData<DataT>(
limit: number,
): Array<DataT> {
let filteredData = filterData<DataT>(data, where);
console.log(filteredData);
if (orderBy) {
const firstOrderBy = orderBy[0];

View File

@ -3,7 +3,7 @@ import { ObjectType } from '@nestjs/graphql';
import { ID } from '@nestjs/graphql';
import { User } from '../user/user.model';
@ObjectType()
@ObjectType({})
export class RefreshToken {
@Field(() => ID, { nullable: false })
id!: string;

View File

@ -1,5 +1,6 @@
import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberCountAggregateInput {
@ -18,7 +19,7 @@ export class WorkspaceMemberCountAggregateInput {
@Field(() => Boolean, { nullable: true })
userId?: true;
@Field(() => Boolean, { nullable: true })
@HideField()
workspaceId?: true;
@Field(() => Boolean, { nullable: true })

View File

@ -1,6 +1,7 @@
import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
import { SortOrder } from '../prisma/sort-order.enum';
import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberCountOrderByAggregateInput {
@ -19,6 +20,6 @@ export class WorkspaceMemberCountOrderByAggregateInput {
@Field(() => SortOrder, { nullable: true })
userId?: keyof typeof SortOrder;
@Field(() => SortOrder, { nullable: true })
@HideField()
workspaceId?: keyof typeof SortOrder;
}

View File

@ -1,5 +1,6 @@
import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberCreateManyInput {
@ -18,6 +19,6 @@ export class WorkspaceMemberCreateManyInput {
@Field(() => String, { nullable: false })
userId!: string;
@Field(() => String, { nullable: false })
@HideField()
workspaceId!: string;
}

View File

@ -1,6 +1,7 @@
import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
import { WorkspaceCreateNestedOneWithoutWorkspaceMemberInput } from '../workspace/workspace-create-nested-one-without-workspace-member.input';
import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberCreateWithoutUserInput {
@ -16,8 +17,6 @@ export class WorkspaceMemberCreateWithoutUserInput {
@Field(() => Date, { nullable: true })
deletedAt?: Date | string;
@Field(() => WorkspaceCreateNestedOneWithoutWorkspaceMemberInput, {
nullable: false,
})
@HideField()
workspace!: WorkspaceCreateNestedOneWithoutWorkspaceMemberInput;
}

View File

@ -2,6 +2,7 @@ import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
import { UserCreateNestedOneWithoutWorkspaceMemberInput } from '../user/user-create-nested-one-without-workspace-member.input';
import { WorkspaceCreateNestedOneWithoutWorkspaceMemberInput } from '../workspace/workspace-create-nested-one-without-workspace-member.input';
import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberCreateInput {
@ -22,8 +23,6 @@ export class WorkspaceMemberCreateInput {
})
user!: UserCreateNestedOneWithoutWorkspaceMemberInput;
@Field(() => WorkspaceCreateNestedOneWithoutWorkspaceMemberInput, {
nullable: false,
})
@HideField()
workspace!: WorkspaceCreateNestedOneWithoutWorkspaceMemberInput;
}

View File

@ -1,5 +1,6 @@
import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberMaxAggregateInput {
@ -18,6 +19,6 @@ export class WorkspaceMemberMaxAggregateInput {
@Field(() => Boolean, { nullable: true })
userId?: true;
@Field(() => Boolean, { nullable: true })
@HideField()
workspaceId?: true;
}

View File

@ -1,6 +1,7 @@
import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
import { SortOrder } from '../prisma/sort-order.enum';
import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberMaxOrderByAggregateInput {
@ -19,6 +20,6 @@ export class WorkspaceMemberMaxOrderByAggregateInput {
@Field(() => SortOrder, { nullable: true })
userId?: keyof typeof SortOrder;
@Field(() => SortOrder, { nullable: true })
@HideField()
workspaceId?: keyof typeof SortOrder;
}

View File

@ -1,5 +1,6 @@
import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberMinAggregateInput {
@ -18,6 +19,6 @@ export class WorkspaceMemberMinAggregateInput {
@Field(() => Boolean, { nullable: true })
userId?: true;
@Field(() => Boolean, { nullable: true })
@HideField()
workspaceId?: true;
}

View File

@ -1,6 +1,7 @@
import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
import { SortOrder } from '../prisma/sort-order.enum';
import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberMinOrderByAggregateInput {
@ -19,6 +20,6 @@ export class WorkspaceMemberMinOrderByAggregateInput {
@Field(() => SortOrder, { nullable: true })
userId?: keyof typeof SortOrder;
@Field(() => SortOrder, { nullable: true })
@HideField()
workspaceId?: keyof typeof SortOrder;
}

View File

@ -1,6 +1,7 @@
import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
import { SortOrder } from '../prisma/sort-order.enum';
import { HideField } from '@nestjs/graphql';
import { WorkspaceMemberCountOrderByAggregateInput } from './workspace-member-count-order-by-aggregate.input';
import { WorkspaceMemberMaxOrderByAggregateInput } from './workspace-member-max-order-by-aggregate.input';
import { WorkspaceMemberMinOrderByAggregateInput } from './workspace-member-min-order-by-aggregate.input';
@ -22,7 +23,7 @@ export class WorkspaceMemberOrderByWithAggregationInput {
@Field(() => SortOrder, { nullable: true })
userId?: keyof typeof SortOrder;
@Field(() => SortOrder, { nullable: true })
@HideField()
workspaceId?: keyof typeof SortOrder;
@Field(() => WorkspaceMemberCountOrderByAggregateInput, { nullable: true })

View File

@ -1,6 +1,7 @@
import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
import { SortOrder } from '../prisma/sort-order.enum';
import { HideField } from '@nestjs/graphql';
import { UserOrderByWithRelationInput } from '../user/user-order-by-with-relation.input';
import { WorkspaceOrderByWithRelationInput } from '../workspace/workspace-order-by-with-relation.input';
@ -21,12 +22,12 @@ export class WorkspaceMemberOrderByWithRelationInput {
@Field(() => SortOrder, { nullable: true })
userId?: keyof typeof SortOrder;
@Field(() => SortOrder, { nullable: true })
@HideField()
workspaceId?: keyof typeof SortOrder;
@Field(() => UserOrderByWithRelationInput, { nullable: true })
user?: UserOrderByWithRelationInput;
@Field(() => WorkspaceOrderByWithRelationInput, { nullable: true })
@HideField()
workspace?: WorkspaceOrderByWithRelationInput;
}

View File

@ -3,6 +3,7 @@ import { InputType } from '@nestjs/graphql';
import { StringWithAggregatesFilter } from '../prisma/string-with-aggregates-filter.input';
import { DateTimeWithAggregatesFilter } from '../prisma/date-time-with-aggregates-filter.input';
import { DateTimeNullableWithAggregatesFilter } from '../prisma/date-time-nullable-with-aggregates-filter.input';
import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberScalarWhereWithAggregatesInput {
@ -36,6 +37,6 @@ export class WorkspaceMemberScalarWhereWithAggregatesInput {
@Field(() => StringWithAggregatesFilter, { nullable: true })
userId?: StringWithAggregatesFilter;
@Field(() => StringWithAggregatesFilter, { nullable: true })
@HideField()
workspaceId?: StringWithAggregatesFilter;
}

View File

@ -3,6 +3,7 @@ import { InputType } from '@nestjs/graphql';
import { StringFilter } from '../prisma/string-filter.input';
import { DateTimeFilter } from '../prisma/date-time-filter.input';
import { DateTimeNullableFilter } from '../prisma/date-time-nullable-filter.input';
import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberScalarWhereInput {
@ -30,6 +31,6 @@ export class WorkspaceMemberScalarWhereInput {
@Field(() => StringFilter, { nullable: true })
userId?: StringFilter;
@Field(() => StringFilter, { nullable: true })
@HideField()
workspaceId?: StringFilter;
}

View File

@ -1,5 +1,6 @@
import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberUncheckedCreateWithoutUserInput {
@ -15,6 +16,6 @@ export class WorkspaceMemberUncheckedCreateWithoutUserInput {
@Field(() => Date, { nullable: true })
deletedAt?: Date | string;
@Field(() => String, { nullable: false })
@HideField()
workspaceId!: string;
}

View File

@ -1,5 +1,6 @@
import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberUncheckedCreateInput {
@ -18,6 +19,6 @@ export class WorkspaceMemberUncheckedCreateInput {
@Field(() => String, { nullable: false })
userId!: string;
@Field(() => String, { nullable: false })
@HideField()
workspaceId!: string;
}

View File

@ -3,6 +3,7 @@ import { InputType } from '@nestjs/graphql';
import { StringFieldUpdateOperationsInput } from '../prisma/string-field-update-operations.input';
import { DateTimeFieldUpdateOperationsInput } from '../prisma/date-time-field-update-operations.input';
import { NullableDateTimeFieldUpdateOperationsInput } from '../prisma/nullable-date-time-field-update-operations.input';
import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberUncheckedUpdateManyInput {
@ -21,6 +22,6 @@ export class WorkspaceMemberUncheckedUpdateManyInput {
@Field(() => StringFieldUpdateOperationsInput, { nullable: true })
userId?: StringFieldUpdateOperationsInput;
@Field(() => StringFieldUpdateOperationsInput, { nullable: true })
@HideField()
workspaceId?: StringFieldUpdateOperationsInput;
}

View File

@ -3,6 +3,7 @@ import { InputType } from '@nestjs/graphql';
import { StringFieldUpdateOperationsInput } from '../prisma/string-field-update-operations.input';
import { DateTimeFieldUpdateOperationsInput } from '../prisma/date-time-field-update-operations.input';
import { NullableDateTimeFieldUpdateOperationsInput } from '../prisma/nullable-date-time-field-update-operations.input';
import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberUncheckedUpdateWithoutUserInput {
@ -18,6 +19,6 @@ export class WorkspaceMemberUncheckedUpdateWithoutUserInput {
@Field(() => NullableDateTimeFieldUpdateOperationsInput, { nullable: true })
deletedAt?: NullableDateTimeFieldUpdateOperationsInput;
@Field(() => StringFieldUpdateOperationsInput, { nullable: true })
@HideField()
workspaceId?: StringFieldUpdateOperationsInput;
}

View File

@ -3,6 +3,7 @@ import { InputType } from '@nestjs/graphql';
import { StringFieldUpdateOperationsInput } from '../prisma/string-field-update-operations.input';
import { DateTimeFieldUpdateOperationsInput } from '../prisma/date-time-field-update-operations.input';
import { NullableDateTimeFieldUpdateOperationsInput } from '../prisma/nullable-date-time-field-update-operations.input';
import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberUncheckedUpdateInput {
@ -21,6 +22,6 @@ export class WorkspaceMemberUncheckedUpdateInput {
@Field(() => StringFieldUpdateOperationsInput, { nullable: true })
userId?: StringFieldUpdateOperationsInput;
@Field(() => StringFieldUpdateOperationsInput, { nullable: true })
@HideField()
workspaceId?: StringFieldUpdateOperationsInput;
}

View File

@ -4,6 +4,7 @@ import { StringFieldUpdateOperationsInput } from '../prisma/string-field-update-
import { DateTimeFieldUpdateOperationsInput } from '../prisma/date-time-field-update-operations.input';
import { NullableDateTimeFieldUpdateOperationsInput } from '../prisma/nullable-date-time-field-update-operations.input';
import { WorkspaceUpdateOneRequiredWithoutWorkspaceMemberNestedInput } from '../workspace/workspace-update-one-required-without-workspace-member-nested.input';
import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberUpdateWithoutUserInput {
@ -19,8 +20,6 @@ export class WorkspaceMemberUpdateWithoutUserInput {
@Field(() => NullableDateTimeFieldUpdateOperationsInput, { nullable: true })
deletedAt?: NullableDateTimeFieldUpdateOperationsInput;
@Field(() => WorkspaceUpdateOneRequiredWithoutWorkspaceMemberNestedInput, {
nullable: true,
})
@HideField()
workspace?: WorkspaceUpdateOneRequiredWithoutWorkspaceMemberNestedInput;
}

View File

@ -5,6 +5,7 @@ import { DateTimeFieldUpdateOperationsInput } from '../prisma/date-time-field-up
import { NullableDateTimeFieldUpdateOperationsInput } from '../prisma/nullable-date-time-field-update-operations.input';
import { UserUpdateOneRequiredWithoutWorkspaceMemberNestedInput } from '../user/user-update-one-required-without-workspace-member-nested.input';
import { WorkspaceUpdateOneRequiredWithoutWorkspaceMemberNestedInput } from '../workspace/workspace-update-one-required-without-workspace-member-nested.input';
import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberUpdateInput {
@ -25,8 +26,6 @@ export class WorkspaceMemberUpdateInput {
})
user?: UserUpdateOneRequiredWithoutWorkspaceMemberNestedInput;
@Field(() => WorkspaceUpdateOneRequiredWithoutWorkspaceMemberNestedInput, {
nullable: true,
})
@HideField()
workspace?: WorkspaceUpdateOneRequiredWithoutWorkspaceMemberNestedInput;
}

View File

@ -3,6 +3,7 @@ import { InputType } from '@nestjs/graphql';
import { StringFilter } from '../prisma/string-filter.input';
import { DateTimeFilter } from '../prisma/date-time-filter.input';
import { DateTimeNullableFilter } from '../prisma/date-time-nullable-filter.input';
import { HideField } from '@nestjs/graphql';
import { UserRelationFilter } from '../user/user-relation-filter.input';
import { WorkspaceRelationFilter } from '../workspace/workspace-relation-filter.input';
@ -32,12 +33,12 @@ export class WorkspaceMemberWhereInput {
@Field(() => StringFilter, { nullable: true })
userId?: StringFilter;
@Field(() => StringFilter, { nullable: true })
@HideField()
workspaceId?: StringFilter;
@Field(() => UserRelationFilter, { nullable: true })
user?: UserRelationFilter;
@Field(() => WorkspaceRelationFilter, { nullable: true })
@HideField()
workspace?: WorkspaceRelationFilter;
}

View File

@ -6,7 +6,7 @@ import { Company } from '../company/company.model';
import { Person } from '../person/person.model';
import { WorkspaceCount } from './workspace-count.output';
@ObjectType()
@ObjectType({})
export class Workspace {
@Field(() => ID, { nullable: false })
id!: string;

View File

@ -3,15 +3,16 @@ import { GraphQLModule } from '@nestjs/graphql';
import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo';
import { CompanyResolver } from './resolvers/company.resolver';
import { UserResolver } from './resolvers/user.resolver';
import { PeopleResolver } from './resolvers/people.resolver';
import { PersonResolver } from './resolvers/person.resolver';
import { PersonRelationsResolver } from './resolvers/relations/people-relations.resolver';
import { PersonRelationsResolver } from './resolvers/relations/person-relations.resolver';
import { UserRelationsResolver } from './resolvers/relations/user-relations.resolver';
import { WorkspaceMemberRelationsResolver } from './resolvers/relations/workspace-member-relations.resolver';
import { ConfigService } from '@nestjs/config';
import { AuthModule } from 'src/auth/auth.module';
import { CompanyRelationsResolver } from './resolvers/relations/company-relations.resolver';
import { PrismaModule } from 'src/database/prisma.module';
import { ArgsService } from './resolvers/services/args.service';
@Module({
imports: [
@ -25,9 +26,10 @@ import { PrismaModule } from 'src/database/prisma.module';
],
providers: [
ConfigService,
ArgsService,
CompanyResolver,
PeopleResolver,
PersonResolver,
UserResolver,
CompanyRelationsResolver,

View File

@ -1,37 +1,39 @@
import { Resolver, Query, Args, Mutation } from '@nestjs/graphql';
import { JwtAuthGuard } from 'src/auth/guards/jwt.auth.guard';
import { UseGuards } from '@nestjs/common';
import { User, UserType } from './decorators/user.decorator';
import { AuthWorkspace } from './decorators/auth-workspace.decorator';
import { PrismaService } from 'src/database/prisma.service';
import { Company } from '../@generated/company/company.model';
import { FindManyCompanyArgs } from '../@generated/company/find-many-company.args';
import { DeleteOneCompanyArgs } from '../@generated/company/delete-one-company.args';
import { UpdateOneCompanyArgs } from '../@generated/company/update-one-company.args';
import { CreateOneCompanyArgs } from '../@generated/company/create-one-company.args';
import { AffectedRows } from '../@generated/prisma/affected-rows.output';
import { DeleteManyCompanyArgs } from '../@generated/company/delete-many-company.args';
import { Workspace } from '@prisma/client';
import { ArgsService } from './services/args.service';
import { CheckWorkspaceOwnership } from 'src/auth/guards/check-workspace-ownership.guard';
@UseGuards(JwtAuthGuard, CheckWorkspaceOwnership)
@Resolver(() => Company)
export class CompanyResolver {
constructor(private readonly prismaService: PrismaService) {}
constructor(
private readonly prismaService: PrismaService,
private readonly argsService: ArgsService,
) {}
@UseGuards(JwtAuthGuard)
@Query(() => [Company])
async companies(@Args() args: FindManyCompanyArgs) {
return this.prismaService.company.findMany(args);
async findManyCompany(
@Args() args: FindManyCompanyArgs,
@AuthWorkspace() workspace: Workspace,
) {
const preparedArgs =
await this.argsService.prepareFindManyArgs<FindManyCompanyArgs>(
args,
workspace,
);
return this.prismaService.company.findMany(preparedArgs);
}
@UseGuards(JwtAuthGuard)
@Mutation(() => Company, {
nullable: true,
})
async deleteOneCompany(
@Args() args: DeleteOneCompanyArgs,
): Promise<Company | null> {
return this.prismaService.company.delete(args);
}
@UseGuards(JwtAuthGuard)
@Mutation(() => Company, {
nullable: true,
})
@ -46,23 +48,6 @@ export class CompanyResolver {
});
}
@UseGuards(JwtAuthGuard)
@Mutation(() => Company, {
nullable: false,
})
async createOneCompany(
@Args() args: CreateOneCompanyArgs,
@User() user: UserType,
): Promise<Company> {
return this.prismaService.company.create({
data: {
...args.data,
...{ workspace: { connect: { id: user.workspaceId } } },
},
});
}
@UseGuards(JwtAuthGuard)
@Mutation(() => AffectedRows, {
nullable: false,
})
@ -73,4 +58,19 @@ export class CompanyResolver {
...args,
});
}
@Mutation(() => Company, {
nullable: false,
})
async createOneCompany(
@Args() args: CreateOneCompanyArgs,
@AuthWorkspace() workspace: Workspace,
): Promise<Company> {
return this.prismaService.company.create({
data: {
...args.data,
...{ workspace: { connect: { id: workspace.id } } },
},
});
}
}

View File

@ -1,14 +1,10 @@
import { ExecutionContext, createParamDecorator } from '@nestjs/common';
import { GqlExecutionContext } from '@nestjs/graphql';
export const User = createParamDecorator(
export const AuthUser = createParamDecorator(
(data: unknown, ctx: ExecutionContext) => {
const gqlContext = GqlExecutionContext.create(ctx);
const request = gqlContext.getContext().req;
return request.user;
},
);
export type UserType = {
workspaceId: string;
};

View File

@ -0,0 +1,10 @@
import { ExecutionContext, createParamDecorator } from '@nestjs/common';
import { GqlExecutionContext } from '@nestjs/graphql';
export const AuthWorkspace = createParamDecorator(
(data: unknown, ctx: ExecutionContext) => {
const gqlContext = GqlExecutionContext.create(ctx);
const request = gqlContext.getContext().req;
return request.workspace;
},
);

View File

@ -1,7 +1,6 @@
import { Resolver, Query, Args, Mutation } from '@nestjs/graphql';
import { UseGuards } from '@nestjs/common';
import { JwtAuthGuard } from 'src/auth/guards/jwt.auth.guard';
import { User, UserType } from './decorators/user.decorator';
import { PrismaService } from 'src/database/prisma.service';
import { Person } from '../@generated/person/person.model';
import { FindManyPersonArgs } from '../@generated/person/find-many-person.args';
@ -9,22 +8,36 @@ import { UpdateOnePersonArgs } from '../@generated/person/update-one-person.args
import { CreateOnePersonArgs } from '../@generated/person/create-one-person.args';
import { AffectedRows } from '../@generated/prisma/affected-rows.output';
import { DeleteManyPersonArgs } from '../@generated/person/delete-many-person.args';
import { Workspace } from '../@generated/workspace/workspace.model';
import { AuthWorkspace } from './decorators/auth-workspace.decorator';
import { ArgsService } from './services/args.service';
import { CheckWorkspaceOwnership } from 'src/auth/guards/check-workspace-ownership.guard';
@UseGuards(JwtAuthGuard, CheckWorkspaceOwnership)
@Resolver(() => Person)
export class PeopleResolver {
constructor(private readonly prismaService: PrismaService) {}
export class PersonResolver {
constructor(
private readonly prismaService: PrismaService,
private readonly argsService: ArgsService,
) {}
@UseGuards(JwtAuthGuard)
@Query(() => [Person], {
nullable: false,
})
async people(@Args() args: FindManyPersonArgs): Promise<Person[]> {
async findManyPerson(
@Args() args: FindManyPersonArgs,
@AuthWorkspace() workspace: Workspace,
): Promise<Person[]> {
const preparedArgs =
await this.argsService.prepareFindManyArgs<FindManyPersonArgs>(
args,
workspace,
);
return this.prismaService.person.findMany({
...args,
...preparedArgs,
});
}
@UseGuards(JwtAuthGuard)
@Mutation(() => Person, {
nullable: true,
})
@ -34,28 +47,12 @@ export class PeopleResolver {
if (!args.data.company?.connect?.id) {
args.data.company = { disconnect: true };
}
return this.prismaService.person.update({
...args,
});
}
@UseGuards(JwtAuthGuard)
@Mutation(() => Person, {
nullable: false,
})
async createOnePerson(
@Args() args: CreateOnePersonArgs,
@User() user: UserType,
): Promise<Person> {
return this.prismaService.person.create({
data: {
...args.data,
...{ workspace: { connect: { id: user.workspaceId } } },
},
});
}
@UseGuards(JwtAuthGuard)
@Mutation(() => AffectedRows, {
nullable: false,
})
@ -66,4 +63,19 @@ export class PeopleResolver {
...args,
});
}
@Mutation(() => Person, {
nullable: false,
})
async createOnePerson(
@Args() args: CreateOnePersonArgs,
@AuthWorkspace() workspace: Workspace,
): Promise<Person> {
return this.prismaService.person.create({
data: {
...args.data,
...{ workspace: { connect: { id: workspace.id } } },
},
});
}
}

View File

@ -0,0 +1,18 @@
import { Injectable } from '@nestjs/common';
import { Workspace } from '@prisma/client';
type FindManyArgsType = { where?: object; orderBy?: object };
@Injectable()
export class ArgsService {
async prepareFindManyArgs<T extends FindManyArgsType>(
args: T,
workspace: Workspace,
): Promise<T> {
args.where = {
...args.where,
...{ workspace: { is: { id: { equals: workspace.id } } } },
};
return args;
}
}

View File

@ -2,31 +2,39 @@ import { Resolver, Query, Args } from '@nestjs/graphql';
import { PrismaService } from 'src/database/prisma.service';
import { UseGuards } from '@nestjs/common';
import { JwtAuthGuard } from 'src/auth/guards/jwt.auth.guard';
import { User } from '../@generated/user/user.model';
import { FindManyUserArgs } from '../@generated/user/find-many-user.args';
import { FindUniqueUserOrThrowArgs } from '../@generated/user/find-unique-user-or-throw.args';
import { Workspace } from '@prisma/client';
import { AuthWorkspace } from './decorators/auth-workspace.decorator';
import { ArgsService } from './services/args.service';
import { CheckWorkspaceOwnership } from 'src/auth/guards/check-workspace-ownership.guard';
@UseGuards(JwtAuthGuard, CheckWorkspaceOwnership)
@Resolver(() => User)
export class UserResolver {
constructor(private readonly prismaService: PrismaService) {}
constructor(
private readonly prismaService: PrismaService,
private readonly argsService: ArgsService,
) {}
@UseGuards(JwtAuthGuard)
@Query(() => [User], {
nullable: false,
})
async users(@Args() args: FindManyUserArgs): Promise<User[]> {
async findManyUser(
@Args() args: FindManyUserArgs,
@AuthWorkspace() workspace: Workspace,
): Promise<User[]> {
args.where = {
...args.where,
...{
WorkspaceMember: {
is: { workspace: { is: { id: { equals: workspace.id } } } },
},
},
};
return await this.prismaService.user.findMany({
...args,
});
}
@UseGuards(JwtAuthGuard)
@Query(() => User, {
nullable: false,
})
async user(@Args() args: FindUniqueUserOrThrowArgs): Promise<User | null> {
return await this.prismaService.user.findUnique({
...args,
});
}
}

View File

@ -8,8 +8,9 @@ import {
UseGuards,
} from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { Request, Response } from 'express';
import { Response } from 'express';
import { AuthService } from './services/auth.service';
import { GoogleRequest } from './strategies/google.auth.strategy';
@Controller('auth/google')
export class GoogleAuthController {
@ -24,10 +25,8 @@ export class GoogleAuthController {
@Get('redirect')
@UseGuards(AuthGuard('google'))
async googleAuthRedirect(@Req() req: Request, @Res() res: Response) {
const user = await this.authService.upsertUser(
req.user as { firstName: string; lastName: string; email: string },
);
async googleAuthRedirect(@Req() req: GoogleRequest, @Res() res: Response) {
const user = await this.authService.upsertUser(req.user);
if (!user) {
throw new HttpException(

View File

@ -0,0 +1,85 @@
import {
CanActivate,
ExecutionContext,
HttpException,
HttpStatus,
Injectable,
} from '@nestjs/common';
import { GqlExecutionContext } from '@nestjs/graphql';
import { Request } from 'express';
import { PrismaService } from 'src/database/prisma.service';
type OperationEntity = {
operation?: string;
entity?: string;
};
@Injectable()
export class CheckWorkspaceOwnership implements CanActivate {
constructor(private prismaService: PrismaService) {}
async canActivate(context: ExecutionContext): Promise<boolean> {
const gqlContext = GqlExecutionContext.create(context);
const request = gqlContext.getContext().req;
const { operation, entity } = this.fetchOperationAndEntity(request);
const variables = request.body.variables;
const workspace = await request.workspace;
if (!entity || !operation) {
return false;
}
if (operation === 'updateOne') {
const object = await this.prismaService[entity].findUniqueOrThrow({
where: { id: variables.id },
});
if (!object) {
throw new HttpException(
{ reason: 'Record not found' },
HttpStatus.NOT_FOUND,
);
}
if (object.workspaceId !== workspace.id) {
throw new HttpException(
{ reason: 'Record not found' },
HttpStatus.NOT_FOUND,
);
}
return true;
}
if (operation === 'deleteMany') {
// TODO: write this logic
return true;
}
if (operation === 'findMany') {
return true;
}
if (operation === 'createOne') {
return true;
}
return false;
}
private fetchOperationAndEntity(request: Request): OperationEntity {
if (!request.body.operationName) {
return { operation: undefined, entity: undefined };
}
const regex =
/(updateOne|deleteMany|createOne|findMany)(Person|Company|User)/i;
const match = request.body.query.match(regex);
if (match) {
return {
operation: match[1],
entity: match[2].toLowerCase(),
};
}
return { operation: undefined, entity: undefined };
}
}

View File

@ -1,6 +1,8 @@
import {
CanActivate,
ExecutionContext,
HttpException,
HttpStatus,
Injectable,
UnauthorizedException,
} from '@nestjs/common';
@ -8,12 +10,15 @@ import { JwtService } from '@nestjs/jwt';
import { GqlExecutionContext } from '@nestjs/graphql';
import { Request } from 'express';
import { ConfigService } from '@nestjs/config';
import { PrismaService } from 'src/database/prisma.service';
import { JwtPayload } from '../strategies/jwt.auth.strategy';
@Injectable()
export class JwtAuthGuard implements CanActivate {
constructor(
private jwtService: JwtService,
private configService: ConfigService,
private prismaService: PrismaService,
) {}
async canActivate(context: ExecutionContext): Promise<boolean> {
@ -24,10 +29,34 @@ export class JwtAuthGuard implements CanActivate {
throw new UnauthorizedException();
}
try {
const payload = await this.jwtService.verifyAsync(token, {
const payload: JwtPayload = await this.jwtService.verifyAsync(token, {
secret: this.configService.get('JWT_SECRET'),
});
request['user'] = payload;
const user = this.prismaService.user.findUniqueOrThrow({
where: { id: payload.userId },
});
if (!user) {
throw new HttpException(
{ reason: 'User does not exist' },
HttpStatus.FORBIDDEN,
);
}
const workspace = this.prismaService.workspace.findUniqueOrThrow({
where: { id: payload.workspaceId },
});
if (!workspace) {
throw new HttpException(
{ reason: 'Workspace does not exist' },
HttpStatus.FORBIDDEN,
);
}
request.user = user;
request.workspace = workspace;
} catch (exception) {
throw new UnauthorizedException();
}

View File

@ -8,6 +8,12 @@ import { RefreshTokenRepository } from 'src/entities/refresh-token/refresh-token
import { v4 } from 'uuid';
import { RefreshToken, User } from '@prisma/client';
export type UserPayload = {
firstName: string;
lastName: string;
email: string;
};
@Injectable()
export class AuthService {
constructor(
@ -18,11 +24,7 @@ export class AuthService {
private refreshTokenRepository: RefreshTokenRepository,
) {}
async upsertUser(rawUser: {
firstName: string;
lastName: string;
email: string;
}) {
async upsertUser(rawUser: UserPayload) {
if (!rawUser.email) {
throw new HttpException(
{ reason: 'Email is missing' },

View File

@ -3,6 +3,11 @@ import { Strategy, VerifyCallback } from 'passport-google-oauth20';
import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { Request } from 'express';
export type GoogleRequest = Request & {
user: { firstName: string; lastName: string; email: string };
};
@Injectable()
export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {

View File

@ -24,7 +24,7 @@ export class JwtAuthStrategy extends PassportStrategy(Strategy, 'jwt') {
});
}
async validate(payload: JwtPayload) {
async validate(payload: JwtPayload): Promise<JwtPayload> {
return { userId: payload.userId, workspaceId: payload.workspaceId };
}
}

View File

@ -35,6 +35,7 @@ model User {
@@map("users")
}
/// @TypeGraphQL.omit(input: true)
model Workspace {
id String @id
createdAt DateTime @default(now())
@ -57,7 +58,9 @@ model WorkspaceMember {
deletedAt DateTime?
userId String @unique
user User @relation(fields: [userId], references: [id])
/// @TypeGraphQL.omit(input: true)
workspaceId String
/// @TypeGraphQL.omit(input: true)
workspace Workspace @relation(fields: [workspaceId], references: [id])
@@map("workspace_members")
@ -105,6 +108,7 @@ model Person {
@@map("people")
}
/// @TypeGraphQL.omit(input: true)
model RefreshToken {
id String @id
createdAt DateTime @default(now())

View File

@ -147,4 +147,16 @@ export const seedCompanies = async (prisma: PrismaClient) => {
address: '',
},
});
await prisma.company.upsert({
where: { id: 'a674fa6c-1455-4c57-afaf-dd5dc086361e' },
update: {},
create: {
id: 'a674fa6c-1455-4c57-afaf-dd5dc086361e',
name: 'Instagram',
domainName: 'instagram.com',
workspaceId: '7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
address: '',
},
});
};

View File

@ -209,4 +209,19 @@ export const seedPeople = async (prisma: PrismaClient) => {
email: 'louis.duss@google.com',
},
});
await prisma.person.upsert({
where: { id: '240da2ec-2d40-4e49-8df4-9c6a049190dh' },
update: {},
create: {
id: '240da2ec-2d40-4e49-8df4-9c6a049190dh',
firstname: 'Lorie',
lastname: 'Vladim',
workspaceId: '7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
phone: '+33788901235',
city: 'Seattle',
companyId: 'a674fa6c-1455-4c57-afaf-dd5dc086361e',
email: 'lorie.vladim@google.com',
},
});
};