Remove hasura and hasura-auth (#134)

* Remove hasura and hasura-auth

* Move all models to prisma

* Start implementing graphql

* chore: clean package json

* chore: make the code build

* chore: get initial graphql.tsx file

* feature: use typegql as qgl server

* refactor: small refactoring

* refactor: clean tests

* bugfix: make all filters not case sensitive

* chore: remove unused imports

---------

Co-authored-by: Sammy Teillet <sammy.teillet@gmail.com>
This commit is contained in:
Charles Bochet
2023-05-24 17:20:15 +02:00
committed by GitHub
parent 7192457d0a
commit 5d06398d2e
177 changed files with 12215 additions and 7040 deletions

View File

@ -49,7 +49,7 @@ const mocks = [
{
request: {
query: GET_PEOPLE,
variables: { orderBy: [{ created_at: 'desc' }], where: {} },
variables: { orderBy: [{ createdAt: 'desc' }], where: {} },
},
result: {
data: {

View File

@ -11,7 +11,7 @@ import { onError } from '@apollo/client/link/error';
import { refreshAccessToken } from './services/auth/AuthService';
const apiLink = createHttpLink({
uri: `${process.env.REACT_APP_API_URL}/v1/graphql`,
uri: `${process.env.REACT_APP_API_URL}`,
});
const withAuthHeadersLink = setContext((_, { headers }) => {

View File

@ -11,6 +11,7 @@ import { MockedProvider } from '@apollo/client/testing';
import { SEARCH_COMPANY_QUERY } from '../../../services/api/search/search';
import styled from '@emotion/styled';
import { SearchConfigType } from '../../../interfaces/search/interface';
import { QueryMode } from '../../../generated/graphql';
const component = {
title: 'editable-cell/EditableRelation',
@ -41,7 +42,7 @@ const mocks = [
request: {
query: SEARCH_COMPANY_QUERY,
variables: {
where: { name: { _ilike: '%%' } },
where: { name: { contains: '%%', mode: QueryMode.Insensitive } },
limit: 5,
},
},
@ -92,7 +93,7 @@ EditableRelationStory.args = {
searchConfig: {
query: SEARCH_COMPANY_QUERY,
template: (searchInput: string) => ({
name: { _ilike: `%${searchInput}%` },
name: { contains: `%${searchInput}%`, mode: QueryMode.Insensitive },
}),
resultMapper: (company) => ({
render: (company) => company.name,

View File

@ -12,6 +12,7 @@ import {
SelectedFilterType,
} from '../../../../interfaces/filters/interface';
import { mockCompaniesData } from '../../../../pages/companies/__tests__/__data__/mock-data';
import { QueryMode } from '../../../../generated/graphql';
const component = {
title: 'FilterDropdownButton',
@ -28,7 +29,10 @@ const mocks = [
{
request: {
query: SEARCH_COMPANY_QUERY,
variables: { where: { name: { _ilike: '%%' } }, limit: 5 },
variables: {
where: { name: { contains: '%%', mode: QueryMode.Insensitive } },
limit: 5,
},
},
result: {
data: {
@ -39,7 +43,10 @@ const mocks = [
{
request: {
query: SEARCH_COMPANY_QUERY,
variables: { where: { name: { _ilike: '%Airc%' } }, limit: 5 },
variables: {
where: { name: { contains: '%Airc%', mode: QueryMode.Insensitive } },
limit: 5,
},
},
result: {
data: {

View File

@ -27,7 +27,7 @@ export const RegularSortAndFilterBar = ({
label: 'Is',
id: 'is',
whereTemplate: (person: Person) => {
return { email: { _eq: person.email } };
return { email: { equals: person.email } };
},
},
key: 'test_filter',

View File

@ -2,7 +2,10 @@ import { ThemeProvider } from '@emotion/react';
import { lightTheme } from '../../../../layout/styles/themes';
import { SortDropdownButton } from '../SortDropdownButton';
import styled from '@emotion/styled';
import { Order_By, People_Order_By } from '../../../../generated/graphql';
import {
SortOrder as Order_By,
PersonOrderByWithRelationInput as People_Order_By,
} from '../../../../generated/graphql';
import { SortType } from '../../../../interfaces/sorts/interface';
import {
TbBuilding,
@ -52,7 +55,7 @@ const availableSorts = [
_type: 'default_sort',
},
{
key: 'created_at',
key: 'createdAt',
label: 'Created at',
icon: <TbCalendar size={16} />,
_type: 'default_sort',

View File

@ -1,4 +1,4 @@
import { Order_By } from '../../../generated/graphql';
import { SortOrder as Order_By } from '../../../generated/graphql';
import { BoolExpType } from '../../../interfaces/entities/generic.interface';
import {
FilterableFieldsType,

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
import {
Companies_Bool_Exp,
People_Bool_Exp,
Users_Bool_Exp,
CompanyWhereInput as Companies_Bool_Exp,
PersonWhereInput as People_Bool_Exp,
UserWhereInput as Users_Bool_Exp,
} from '../../generated/graphql';
import { Company, GraphqlQueryCompany } from './company.interface';
import { GraphqlQueryPerson, Person } from './person.interface';

View File

@ -1,5 +1,5 @@
import { ReactNode } from 'react';
import { Order_By } from '../../generated/graphql';
import { SortOrder as Order_By } from '../../generated/graphql';
export type SortType<OrderByTemplate> =
| {

View File

@ -20,7 +20,7 @@ import {
reduceFiltersToWhere,
reduceSortsToOrderBy,
} from '../../components/table/table-header/helpers';
import { Companies_Order_By } from '../../generated/graphql';
import { CompanyOrderByWithRelationInput as Companies_Order_By } from '../../generated/graphql';
import ActionBar from '../../components/table/action-bar/ActionBar';
import { SelectedFilterType } from '../../interfaces/filters/interface';
import { BoolExpType } from '../../interfaces/entities/generic.interface';

View File

@ -5,6 +5,7 @@ import { lightTheme } from '../../../layout/styles/themes';
import { GET_COMPANIES } from '../../../services/api/companies';
import { mockCompaniesData } from '../__tests__/__data__/mock-data';
import { MockedProvider } from '@apollo/client/testing';
import { QueryMode } from '../../../generated/graphql';
const component = {
title: 'Companies',
@ -18,7 +19,7 @@ const mocks = [
request: {
query: GET_COMPANIES,
variables: {
orderBy: [{ created_at: 'desc' }],
orderBy: [{ createdAt: 'desc' }],
where: {},
},
},
@ -32,7 +33,7 @@ const mocks = [
request: {
query: GET_COMPANIES,
variables: {
orderBy: [{ created_at: 'desc' }],
orderBy: [{ createdAt: 'desc' }],
where: {},
},
},
@ -46,8 +47,10 @@ const mocks = [
request: {
query: GET_COMPANIES,
variables: {
orderBy: [{ created_at: 'desc' }],
where: { domain_name: { _ilike: '%aircal%' } },
orderBy: [{ createdAt: 'desc' }],
where: {
domainName: { contains: '%aircal%', mode: QueryMode.Insensitive },
},
},
},
result: {

View File

@ -3,7 +3,7 @@
exports[`Companies Filter should render the filter company_employees 1`] = `
Object {
"employees": Object {
"_gte": 2,
"gte": 2,
},
}
`;
@ -11,7 +11,8 @@ Object {
exports[`Companies Filter should render the filter company_name 1`] = `
Object {
"name": Object {
"_ilike": "%name%",
"contains": "%name%",
"mode": "insensitive",
},
}
`;

View File

@ -27,6 +27,7 @@ import {
TbSum,
TbUser,
} from 'react-icons/tb';
import { QueryMode } from '../../generated/graphql';
const columnHelper = createColumnHelper<Company>();
@ -178,7 +179,10 @@ export const useCompaniesColumns = () => {
{
query: SEARCH_USER_QUERY,
template: (searchInput: string) => ({
displayName: { _ilike: `%${searchInput}%` },
displayName: {
contains: `%${searchInput}%`,
mode: QueryMode.Insensitive,
},
}),
resultMapper: (accountOwner) => ({
render: (accountOwner) => accountOwner.displayName,

View File

@ -10,6 +10,7 @@ import { Company } from '../../interfaces/entities/company.interface';
import { FilterConfigType } from '../../interfaces/filters/interface';
import { SEARCH_USER_QUERY } from '../../services/api/search/search';
import { User, mapToUser } from '../../interfaces/entities/user.interface';
import { QueryMode } from '../../generated/graphql';
export const nameFilter = {
key: 'company_name',
@ -21,14 +22,21 @@ export const nameFilter = {
label: 'Contains',
id: 'like',
whereTemplate: (searchString) => ({
name: { _ilike: `%${searchString}%` },
name: { contains: `%${searchString}%`, mode: QueryMode.Insensitive },
}),
},
{
label: 'Does not contain',
id: 'not_like',
whereTemplate: (searchString) => ({
_not: { name: { _ilike: `%${searchString}%` } },
NOT: [
{
name: {
contains: `%${searchString}%`,
mode: QueryMode.Insensitive,
},
},
],
}),
},
],
@ -45,7 +53,7 @@ export const employeesFilter = {
id: 'greater_than',
whereTemplate: (searchString) => ({
employees: {
_gte: isNaN(Number(searchString)) ? undefined : Number(searchString),
gte: isNaN(Number(searchString)) ? undefined : Number(searchString),
},
}),
},
@ -54,7 +62,7 @@ export const employeesFilter = {
id: 'less_than',
whereTemplate: (searchString) => ({
employees: {
_lte: isNaN(Number(searchString)) ? undefined : Number(searchString),
lte: isNaN(Number(searchString)) ? undefined : Number(searchString),
},
}),
},
@ -71,14 +79,24 @@ export const urlFilter = {
label: 'Contains',
id: 'like',
whereTemplate: (searchString) => ({
domain_name: { _ilike: `%${searchString}%` },
domainName: {
contains: `%${searchString}%`,
mode: QueryMode.Insensitive,
},
}),
},
{
label: 'Does not contain',
id: 'not_like',
whereTemplate: (searchString) => ({
_not: { domain_name: { _ilike: `%${searchString}%` } },
NOT: [
{
domainName: {
contains: `%${searchString}%`,
mode: QueryMode.Insensitive,
},
},
],
}),
},
],
@ -94,14 +112,21 @@ export const addressFilter = {
label: 'Contains',
id: 'like',
whereTemplate: (searchString) => ({
address: { _ilike: `%${searchString}%` },
address: { contains: `%${searchString}%`, mode: QueryMode.Insensitive },
}),
},
{
label: 'Does not contain',
id: 'not_like',
whereTemplate: (searchString) => ({
_not: { address: { _ilike: `%${searchString}%` } },
NOT: [
{
address: {
contains: `%${searchString}%`,
mode: QueryMode.Insensitive,
},
},
],
}),
},
],
@ -117,8 +142,8 @@ export const creationDateFilter = {
label: 'Greater than',
id: 'greater_than',
whereTemplate: (searchString) => ({
created_at: {
_gte: searchString,
createdAt: {
gte: searchString,
},
}),
},
@ -126,8 +151,8 @@ export const creationDateFilter = {
label: 'Less than',
id: 'less_than',
whereTemplate: (searchString) => ({
created_at: {
_lte: searchString,
createdAt: {
lte: searchString,
},
}),
},
@ -142,7 +167,10 @@ export const accountOwnerFilter = {
searchConfig: {
query: SEARCH_USER_QUERY,
template: (searchString: string) => ({
displayName: { _ilike: `%${searchString}%` },
displayName: {
contains: `%${searchString}%`,
mode: QueryMode.Insensitive,
},
}),
resultMapper: (data) => ({
value: mapToUser(data),
@ -155,14 +183,20 @@ export const accountOwnerFilter = {
label: 'Is',
id: 'is',
whereTemplate: (owner) => ({
account_owner: { displayName: { _eq: owner.displayName } },
accountOwner: { is: { displayName: { equals: owner.displayName } } },
}),
},
{
label: 'Is not',
id: 'is_not',
whereTemplate: (owner) => ({
_not: { account_owner: { displayName: { _eq: owner.displayName } } },
NOT: [
{
accountOwner: {
is: { displayName: { equals: owner.displayName } },
},
},
],
}),
},
],

View File

@ -5,7 +5,7 @@ import {
TbMapPin,
TbSum,
} from 'react-icons/tb';
import { Companies_Order_By } from '../../generated/graphql';
import { CompanyOrderByWithRelationInput as Companies_Order_By } from '../../generated/graphql';
import { SortType } from '../../interfaces/sorts/interface';
export const availableSorts = [
@ -22,7 +22,7 @@ export const availableSorts = [
_type: 'default_sort',
},
{
key: 'domain_name',
key: 'domainName',
label: 'Url',
icon: <TbLink size={16} />,
_type: 'default_sort',
@ -34,7 +34,7 @@ export const availableSorts = [
_type: 'default_sort',
},
{
key: 'created_at',
key: 'createdAt',
label: 'Creation',
icon: <TbCalendar size={16} />,
_type: 'default_sort',

View File

@ -19,7 +19,7 @@ const mocks = [
request: {
query: GET_PEOPLE,
variables: {
orderBy: [{ created_at: 'desc' }],
orderBy: [{ createdAt: 'desc' }],
where: {},
},
},
@ -33,7 +33,7 @@ const mocks = [
request: {
query: GET_PEOPLE,
variables: {
orderBy: [{ created_at: 'desc' }],
orderBy: [{ createdAt: 'desc' }],
where: {},
},
},

View File

@ -3,7 +3,8 @@
exports[`PeopleFilter should render the filter city which is text search 1`] = `
Object {
"city": Object {
"_ilike": "%Paris%",
"contains": "%Paris%",
"mode": "insensitive",
},
}
`;
@ -11,8 +12,10 @@ Object {
exports[`PeopleFilter should render the filter company_name which relation search 1`] = `
Object {
"company": Object {
"name": Object {
"_eq": "test-name",
"is": Object {
"name": Object {
"equals": "test-name",
},
},
},
}

View File

@ -30,6 +30,7 @@ import {
TbPhone,
TbUser,
} from 'react-icons/tb';
import { QueryMode } from '../../generated/graphql';
const columnHelper = createColumnHelper<Person>();
@ -118,7 +119,10 @@ export const usePeopleColumns = () => {
{
query: SEARCH_COMPANY_QUERY,
template: (searchInput: string) => ({
name: { _ilike: `%${searchInput}%` },
name: {
contains: `%${searchInput}%`,
mode: QueryMode.Insensitive,
},
}),
resultMapper: (company) => ({
render: (company) => company.name,

View File

@ -13,6 +13,7 @@ import {
TbPhone,
TbUser,
} from 'react-icons/tb';
import { QueryMode } from '../../generated/graphql';
export const fullnameFilter = {
key: 'fullname',
@ -24,9 +25,19 @@ export const fullnameFilter = {
label: 'Contains',
id: 'like',
whereTemplate: (searchString) => ({
_or: [
{ firstname: { _ilike: `%${searchString}%` } },
{ lastname: { _ilike: `%${searchString}%` } },
OR: [
{
firstname: {
contains: `%${searchString}%`,
mode: QueryMode.Insensitive,
},
},
{
lastname: {
contains: `%${searchString}%`,
mode: QueryMode.Insensitive,
},
},
],
}),
},
@ -34,12 +45,24 @@ export const fullnameFilter = {
label: 'Does not contain',
id: 'not_like',
whereTemplate: (searchString) => ({
_not: {
_and: [
{ firstname: { _ilike: `%${searchString}%` } },
{ lastname: { _ilike: `%${searchString}%` } },
],
},
NOT: [
{
AND: [
{
firstname: {
contains: `%${searchString}%`,
mode: QueryMode.Insensitive,
},
},
{
lastname: {
contains: `%${searchString}%`,
mode: QueryMode.Insensitive,
},
},
],
},
],
}),
},
],
@ -55,14 +78,21 @@ export const emailFilter = {
label: 'Contains',
id: 'like',
whereTemplate: (searchString) => ({
email: { _ilike: `%${searchString}%` },
email: { contains: `%${searchString}%`, mode: QueryMode.Insensitive },
}),
},
{
label: 'Does not contain',
id: 'not_like',
whereTemplate: (searchString) => ({
_not: { email: { _ilike: `%${searchString}%` } },
NOT: [
{
email: {
contains: `%${searchString}%`,
mode: QueryMode.Insensitive,
},
},
],
}),
},
],
@ -76,7 +106,7 @@ export const companyFilter = {
searchConfig: {
query: SEARCH_COMPANY_QUERY,
template: (searchString: string) => ({
name: { _ilike: `%${searchString}%` },
name: { contains: `%${searchString}%`, mode: QueryMode.Insensitive },
}),
resultMapper: (data) => ({
value: mapToCompany(data),
@ -89,14 +119,14 @@ export const companyFilter = {
label: 'Is',
id: 'is',
whereTemplate: (company) => ({
company: { name: { _eq: company.name } },
company: { is: { name: { equals: company.name } } },
}),
},
{
label: 'Is not',
id: 'is_not',
whereTemplate: (company) => ({
_not: { company: { name: { _eq: company.name } } },
NOT: [{ company: { is: { name: { equals: company.name } } } }],
}),
},
],
@ -112,14 +142,21 @@ export const phoneFilter = {
label: 'Contains',
id: 'like',
whereTemplate: (searchString) => ({
phone: { _ilike: `%${searchString}%` },
phone: { contains: `%${searchString}%`, mode: QueryMode.Insensitive },
}),
},
{
label: 'Does not contain',
id: 'not_like',
whereTemplate: (searchString) => ({
_not: { phone: { _ilike: `%${searchString}%` } },
NOT: [
{
phone: {
contains: `%${searchString}%`,
mode: QueryMode.Insensitive,
},
},
],
}),
},
],
@ -135,8 +172,8 @@ export const creationDateFilter = {
label: 'Greater than',
id: 'greater_than',
whereTemplate: (searchString) => ({
created_at: {
_gte: searchString,
createdAt: {
gte: searchString,
},
}),
},
@ -144,8 +181,8 @@ export const creationDateFilter = {
label: 'Less than',
id: 'less_than',
whereTemplate: (searchString) => ({
created_at: {
_lte: searchString,
createdAt: {
lte: searchString,
},
}),
},
@ -162,14 +199,21 @@ export const cityFilter = {
label: 'Contains',
id: 'like',
whereTemplate: (searchString) => ({
city: { _ilike: `%${searchString}%` },
city: { contains: `%${searchString}%`, mode: QueryMode.Insensitive },
}),
},
{
label: 'Does not contain',
id: 'not_like',
whereTemplate: (searchString) => ({
_not: { city: { _ilike: `%${searchString}%` } },
NOT: [
{
city: {
contains: `%${searchString}%`,
mode: QueryMode.Insensitive,
},
},
],
}),
},
],

View File

@ -1,4 +1,7 @@
import { Order_By, People_Order_By } from '../../generated/graphql';
import {
SortOrder as Order_By,
PersonOrderByWithRelationInput as People_Order_By,
} from '../../generated/graphql';
import { SortType } from '../../interfaces/sorts/interface';
import {
TbBuilding,
@ -40,7 +43,7 @@ export const availableSorts = [
_type: 'default_sort',
},
{
key: 'created_at',
key: 'createdAt',
label: 'Created at',
icon: <TbCalendar size={16} />,
_type: 'default_sort',

View File

@ -1,8 +1,8 @@
import { QueryResult, gql, useQuery } from '@apollo/client';
import {
Order_By,
Companies_Order_By,
Companies_Bool_Exp,
SortOrder as Order_By,
CompanyOrderByWithRelationInput as Companies_Order_By,
CompanyWhereInput as Companies_Bool_Exp,
} from '../../../generated/graphql';
import { GraphqlQueryCompany } from '../../../interfaces/entities/company.interface';
import { SelectedSortType } from '../../../interfaces/sorts/interface';
@ -11,17 +11,17 @@ export type CompaniesSelectedSortType = SelectedSortType<Companies_Order_By>;
export const GET_COMPANIES = gql`
query GetCompanies(
$orderBy: [companies_order_by!]
$where: companies_bool_exp
$orderBy: [CompanyOrderByWithRelationInput!]
$where: CompanyWhereInput
) {
companies(order_by: $orderBy, where: $where) {
companies(orderBy: $orderBy, where: $where) {
id
domain_name
domain_name: domainName
name
created_at
created_at: createdAt
address
employees
account_owner {
account_owner: accountOwner {
id
email
displayName
@ -41,6 +41,6 @@ export function useCompaniesQuery(
export const defaultOrderBy: Companies_Order_By[] = [
{
created_at: Order_By.Desc,
createdAt: Order_By.Desc,
},
];

View File

@ -7,88 +7,76 @@ import { apiClient } from '../../../apollo';
export const UPDATE_COMPANY = gql`
mutation UpdateCompany(
$id: uuid
$id: String
$name: String
$domain_name: String
$account_owner_id: uuid
$created_at: timestamptz
$account_owner_id: String
$created_at: DateTime
$address: String
$employees: numeric
$employees: Int
) {
update_companies(
where: { id: { _eq: $id } }
_set: {
account_owner_id: $account_owner_id
address: $address
domain_name: $domain_name
employees: $employees
name: $name
created_at: $created_at
updateOneCompany(
where: { id: $id }
data: {
accountOwner: { connect: { id: $account_owner_id } }
address: { set: $address }
domainName: { set: $domain_name }
employees: { set: $employees }
name: { set: $name }
createdAt: { set: $created_at }
}
) {
affected_rows
returning {
account_owner {
id
email
displayName
}
address
created_at
domain_name
employees
accountOwner {
id
name
email
display_name: displayName
}
address
created_at: createdAt
domain_name: domainName
employees
id
name
}
}
`;
export const INSERT_COMPANY = gql`
mutation InsertCompany(
$id: uuid
$name: String
$domain_name: String
$account_owner_id: uuid
$created_at: timestamptz
$address: String
$employees: numeric
$id: String!
$name: String!
$domain_name: String!
$account_owner_id: String
$created_at: DateTime
$address: String!
$employees: Int
) {
insert_companies(
objects: {
createOneCompany(
data: {
id: $id
name: $name
domain_name: $domain_name
account_owner_id: $account_owner_id
created_at: $created_at
domainName: $domain_name
accountOwner: { connect: { id: $account_owner_id } }
createdAt: $created_at
address: $address
employees: $employees
workspace: { connect: { id: "il faut rajouter l'id du workspace" } }
}
) {
affected_rows
returning {
address
created_at
domain_name
employees
id
name
}
address
created_at: createdAt
domain_name: domainName
employees
id
name
}
}
`;
export const DELETE_COMPANIES = gql`
mutation DeleteCompanies($ids: [uuid!]) {
delete_companies(where: { id: { _in: $ids } }) {
returning {
address
created_at
domain_name
employees
id
name
}
mutation DeleteCompanies($ids: [String!]) {
deleteManyCompany(where: { id: { in: $ids } }) {
count
}
}
`;

View File

@ -1,9 +1,9 @@
import { QueryResult, gql, useQuery } from '@apollo/client';
import { GraphqlQueryPerson } from '../../../interfaces/entities/person.interface';
import {
Order_By,
People_Bool_Exp,
People_Order_By,
PersonWhereInput as People_Bool_Exp,
PersonOrderByWithRelationInput as People_Order_By,
SortOrder,
} from '../../../generated/graphql';
import { SelectedSortType } from '../../../interfaces/sorts/interface';
@ -11,22 +11,22 @@ export type PeopleSelectedSortType = SelectedSortType<People_Order_By>;
export const GET_PEOPLE = gql`
query GetPeople(
$orderBy: [people_order_by!]
$where: people_bool_exp
$orderBy: [PersonOrderByWithRelationInput!]
$where: PersonWhereInput
$limit: Int
) {
people(order_by: $orderBy, where: $where, limit: $limit) {
people(orderBy: $orderBy, where: $where, take: $limit) {
id
phone
email
city
firstname
lastname
created_at
created_at: createdAt
company {
id
name
domain_name
domain_name: domainName
}
}
}
@ -43,6 +43,6 @@ export function usePeopleQuery(
export const defaultOrderBy: People_Order_By[] = [
{
created_at: Order_By.Desc,
createdAt: SortOrder.Desc,
},
];

View File

@ -7,105 +7,88 @@ import { apiClient } from '../../../apollo';
export const UPDATE_PERSON = gql`
mutation UpdatePeople(
$id: uuid
$id: String
$firstname: String
$lastname: String
$phone: String
$city: String
$company_id: uuid
$company_id: String
$email: String
$created_at: timestamptz
$created_at: DateTime
) {
update_people(
where: { id: { _eq: $id } }
_set: {
city: $city
company_id: $company_id
email: $email
firstname: $firstname
id: $id
lastname: $lastname
phone: $phone
created_at: $created_at
updateOnePerson(
where: { id: $id }
data: {
city: { set: $city }
company: { connect: { id: $company_id } }
email: { set: $email }
firstname: { set: $firstname }
id: { set: $id }
lastname: { set: $lastname }
phone: { set: $phone }
createdAt: { set: $created_at }
}
) {
returning {
city
company {
domain_name
name
id
}
email
firstname
city
company {
domain_name: domainName
name
id
lastname
phone
created_at
}
email
firstname
id
lastname
phone
created_at: createdAt
}
}
`;
export const INSERT_PERSON = gql`
mutation InsertPerson(
$id: uuid
$firstname: String
$lastname: String
$phone: String
$city: String
$company_id: uuid
$email: String
$created_at: timestamptz
$id: String!
$firstname: String!
$lastname: String!
$phone: String!
$city: String!
$company_id: String
$email: String!
$created_at: DateTime
) {
insert_people(
objects: {
createOnePerson(
data: {
id: $id
firstname: $firstname
lastname: $lastname
phone: $phone
city: $city
company_id: $company_id
company: { connect: { id: $company_id } }
email: $email
created_at: $created_at
createdAt: $created_at
workspace: { connect: { id: "il faut rajouter l'id du workspace" } }
}
) {
affected_rows
returning {
city
company {
domain_name
name
id
}
email
firstname
city
company {
domain_name: domainName
name
id
lastname
phone
created_at
}
email
firstname
id
lastname
phone
created_at: createdAt
}
}
`;
export const DELETE_PEOPLE = gql`
mutation DeletePeople($ids: [uuid!]) {
delete_people(where: { id: { _in: $ids } }) {
returning {
city
company {
domain_name
name
id
}
email
firstname
id
lastname
phone
created_at
}
mutation DeletePeople($ids: [String!]) {
deleteManyPerson(where: { id: { in: $ids } }) {
count
}
}
`;

View File

@ -7,22 +7,22 @@ import {
} from '../../../interfaces/entities/generic.interface';
export const SEARCH_PEOPLE_QUERY = gql`
query SearchPeopleQuery($where: people_bool_exp, $limit: Int) {
searchResults: people(where: $where, limit: $limit) {
query SearchPeopleQuery($where: PersonWhereInput, $limit: Int) {
searchResults: people(where: $where, take: $limit) {
id
phone
email
city
firstname
lastname
created_at
createdAt
}
}
`;
export const SEARCH_USER_QUERY = gql`
query SearchUserQuery($where: users_bool_exp, $limit: Int) {
searchResults: users(where: $where, limit: $limit) {
query SearchUserQuery($where: UserWhereInput, $limit: Int) {
searchResults: users(where: $where, take: $limit) {
id
email
displayName
@ -39,11 +39,11 @@ export const EMPTY_QUERY = gql`
`;
export const SEARCH_COMPANY_QUERY = gql`
query SearchQuery($where: companies_bool_exp, $limit: Int) {
searchResults: companies(where: $where, limit: $limit) {
query SearchQuery($where: CompanyWhereInput, $limit: Int) {
searchResults: companies(where: $where, take: $limit) {
id
name
domain_name
domain_name: domainName
}
}
`;

View File

@ -2,17 +2,16 @@ import { QueryResult, gql, useQuery } from '@apollo/client';
import { GraphqlQueryUser } from '../../../interfaces/entities/user.interface';
export const GET_CURRENT_USER = gql`
query GetCurrentUser($uuid: uuid) {
users(where: { id: { _eq: $uuid } }) {
query GetCurrentUser($uuid: String) {
users(where: { id: { equals: $uuid } }) {
id
email
displayName
workspace_member {
workspace_member: workspaceMember {
workspace {
id
domain_name
display_name
logo
domain_name: domainName
display_name: displayName
}
}
}

View File

@ -0,0 +1,9 @@
import { gql } from '@apollo/client';
export const GET_CURRENT_USER = gql`
query getUsers {
users {
id
}
}
`;