Skip to content

Commit

Permalink
GraphQL Topic and Review types
Browse files Browse the repository at this point in the history
  • Loading branch information
Fi1osof committed Mar 6, 2021
1 parent b48159a commit 8de6e94
Show file tree
Hide file tree
Showing 41 changed files with 1,738 additions and 165 deletions.
150 changes: 149 additions & 1 deletion server/nexus/generated/nexus.ts
Expand Up @@ -593,11 +593,49 @@ export interface NexusGenObjects {
template: number // Int!
uri?: string | null // String
}
Review: {
// root type
CreatedBy?: NexusGenRootTypes['User'] | null // User
TemplateVarValues?:
| NexusGenRootTypes['bani684_site_tmplvar_contentvalues'][]
| null // [bani684_site_tmplvar_contentvalues!]
alias?: string | null // String
content?: string | null // String
createdby: number // Int!
createdon: NexusGenScalars['DateTime'] // DateTime!
description: string // String!
id: number // Int!
longtitle: string // String!
pagetitle: string // String!
published: boolean // Boolean!
searchable: boolean // Boolean!
template: number // Int!
uri?: string | null // String
}
Thread: {
// root type
id: number // Int!
target_class: string // String!
}
Topic: {
// root type
CreatedBy?: NexusGenRootTypes['User'] | null // User
TemplateVarValues?:
| NexusGenRootTypes['bani684_site_tmplvar_contentvalues'][]
| null // [bani684_site_tmplvar_contentvalues!]
alias?: string | null // String
content?: string | null // String
createdby: number // Int!
createdon: NexusGenScalars['DateTime'] // DateTime!
description: string // String!
id: number // Int!
longtitle: string // String!
pagetitle: string // String!
published: boolean // Boolean!
searchable: boolean // Boolean!
template: number // Int!
uri?: string | null // String
}
User: {
// root type
Attributes?: NexusGenRootTypes['UserAttributes'] | null // UserAttributes
Expand Down Expand Up @@ -627,6 +665,8 @@ export interface NexusGenInterfaces {
| NexusGenRootTypes['Company']
| NexusGenRootTypes['Rating']
| NexusGenRootTypes['Resource']
| NexusGenRootTypes['Review']
| NexusGenRootTypes['Topic']
}

export interface NexusGenUnions {}
Expand Down Expand Up @@ -719,6 +759,8 @@ export interface NexusGenFieldTypes {
ratings: NexusGenRootTypes['Rating'][] // [Rating!]!
resources: NexusGenRootTypes['ResourceInterface'][] // [ResourceInterface!]!
resourcesCount: number // Int!
reviews: NexusGenRootTypes['Review'][] // [Review!]!
topics: NexusGenRootTypes['Topic'][] // [Topic!]!
user: NexusGenRootTypes['User'] | null // User
users: NexusGenRootTypes['User'][] // [User!]!
usersCount: number // Int!
Expand Down Expand Up @@ -765,11 +807,53 @@ export interface NexusGenFieldTypes {
template: number // Int!
uri: string | null // String
}
Review: {
// field return type
Comments: NexusGenRootTypes['Comment'][] // [Comment!]!
CreatedBy: NexusGenRootTypes['User'] | null // User
TemplateVarValues:
| NexusGenRootTypes['bani684_site_tmplvar_contentvalues'][]
| null // [bani684_site_tmplvar_contentvalues!]
alias: string | null // String
content: string | null // String
createdby: number // Int!
createdon: NexusGenScalars['DateTime'] // DateTime!
description: string // String!
id: number // Int!
image: string | null // String
longtitle: string // String!
pagetitle: string // String!
published: boolean // Boolean!
searchable: boolean // Boolean!
template: number // Int!
uri: string | null // String
}
Thread: {
// field return type
id: number // Int!
target_class: string // String!
}
Topic: {
// field return type
Comments: NexusGenRootTypes['Comment'][] // [Comment!]!
CreatedBy: NexusGenRootTypes['User'] | null // User
TemplateVarValues:
| NexusGenRootTypes['bani684_site_tmplvar_contentvalues'][]
| null // [bani684_site_tmplvar_contentvalues!]
alias: string | null // String
content: string | null // String
createdby: number // Int!
createdon: NexusGenScalars['DateTime'] // DateTime!
description: string // String!
id: number // Int!
image: string | null // String
longtitle: string // String!
pagetitle: string // String!
published: boolean // Boolean!
searchable: boolean // Boolean!
template: number // Int!
uri: string | null // String
}
User: {
// field return type
Attributes: NexusGenRootTypes['UserAttributes'] | null // UserAttributes
Expand Down Expand Up @@ -895,6 +979,8 @@ export interface NexusGenFieldTypeNames {
ratings: 'Rating'
resources: 'ResourceInterface'
resourcesCount: 'Int'
reviews: 'Review'
topics: 'Topic'
user: 'User'
users: 'User'
usersCount: 'Int'
Expand Down Expand Up @@ -937,11 +1023,49 @@ export interface NexusGenFieldTypeNames {
template: 'Int'
uri: 'String'
}
Review: {
// field return type name
Comments: 'Comment'
CreatedBy: 'User'
TemplateVarValues: 'bani684_site_tmplvar_contentvalues'
alias: 'String'
content: 'String'
createdby: 'Int'
createdon: 'DateTime'
description: 'String'
id: 'Int'
image: 'String'
longtitle: 'String'
pagetitle: 'String'
published: 'Boolean'
searchable: 'Boolean'
template: 'Int'
uri: 'String'
}
Thread: {
// field return type name
id: 'Int'
target_class: 'String'
}
Topic: {
// field return type name
Comments: 'Comment'
CreatedBy: 'User'
TemplateVarValues: 'bani684_site_tmplvar_contentvalues'
alias: 'String'
content: 'String'
createdby: 'Int'
createdon: 'DateTime'
description: 'String'
id: 'Int'
image: 'String'
longtitle: 'String'
pagetitle: 'String'
published: 'Boolean'
searchable: 'Boolean'
template: 'Int'
uri: 'String'
}
User: {
// field return type name
Attributes: 'UserAttributes'
Expand Down Expand Up @@ -1036,6 +1160,22 @@ export interface NexusGenArgTypes {
// args
where?: NexusGenInputs['bani684_site_contentWhereInput'] | null // bani684_site_contentWhereInput
}
reviews: {
// args
cursor?: NexusGenInputs['bani684_site_contentWhereUniqueInput'] | null // bani684_site_contentWhereUniqueInput
orderBy?: NexusGenInputs['bani684_site_contentOrderByInput'][] | null // [bani684_site_contentOrderByInput!]
skip?: number | null // Int
take?: number | null // Int
where?: NexusGenInputs['bani684_site_contentWhereInput'] | null // bani684_site_contentWhereInput
}
topics: {
// args
cursor?: NexusGenInputs['bani684_site_contentWhereUniqueInput'] | null // bani684_site_contentWhereUniqueInput
orderBy?: NexusGenInputs['bani684_site_contentOrderByInput'][] | null // [bani684_site_contentOrderByInput!]
skip?: number | null // Int
take?: number | null // Int
where?: NexusGenInputs['bani684_site_contentWhereInput'] | null // bani684_site_contentWhereInput
}
user: {
// args
where: NexusGenInputs['bani684_usersWhereUniqueInput'] // bani684_usersWhereUniqueInput!
Expand All @@ -1056,14 +1196,22 @@ export interface NexusGenArgTypes {
}

export interface NexusGenAbstractTypeMembers {
ResourceInterface: 'City' | 'Company' | 'Rating' | 'Resource'
ResourceInterface:
| 'City'
| 'Company'
| 'Rating'
| 'Resource'
| 'Review'
| 'Topic'
}

export interface NexusGenTypeInterfaces {
City: 'ResourceInterface'
Company: 'ResourceInterface'
Rating: 'ResourceInterface'
Resource: 'ResourceInterface'
Review: 'ResourceInterface'
Topic: 'ResourceInterface'
}

export type NexusGenObjectNames = keyof NexusGenObjects
Expand Down
72 changes: 72 additions & 0 deletions server/nexus/generated/schema.graphql
Expand Up @@ -311,6 +311,28 @@ type Query {
Количество ресурсов
"""
resourcesCount(where: bani684_site_contentWhereInput): Int!

"""
Обзоры заведений
"""
reviews(
cursor: bani684_site_contentWhereUniqueInput
orderBy: [bani684_site_contentOrderByInput!]
skip: Int
take: Int
where: bani684_site_contentWhereInput
): [Review!]!

"""
Новости
"""
topics(
cursor: bani684_site_contentWhereUniqueInput
orderBy: [bani684_site_contentOrderByInput!]
skip: Int
take: Int
where: bani684_site_contentWhereInput
): [Topic!]!
user(where: bani684_usersWhereUniqueInput!): User
users(
cursor: bani684_usersWhereUniqueInput
Expand Down Expand Up @@ -395,6 +417,31 @@ interface ResourceInterface {
uri: String
}

"""
Отзыв о заведении
"""
type Review implements ResourceInterface {
"""
Комментарии
"""
Comments: [Comment!]!
CreatedBy: User
TemplateVarValues: [bani684_site_tmplvar_contentvalues!]
alias: String
content: String
createdby: Int!
createdon: DateTime!
description: String!
id: Int!
image: String
longtitle: String!
pagetitle: String!
published: Boolean!
searchable: Boolean!
template: Int!
uri: String
}

enum SortOrder {
asc
desc
Expand Down Expand Up @@ -436,6 +483,31 @@ type Thread {
target_class: String!
}

"""
Топик
"""
type Topic implements ResourceInterface {
"""
Комментарии
"""
Comments: [Comment!]!
CreatedBy: User
TemplateVarValues: [bani684_site_tmplvar_contentvalues!]
alias: String
content: String
createdby: Int!
createdon: DateTime!
description: String!
id: Int!
image: String
longtitle: String!
pagetitle: String!
published: Boolean!
searchable: Boolean!
template: Int!
uri: String
}

"""
Пользователь
"""
Expand Down
70 changes: 70 additions & 0 deletions server/nexus/types/Query/definitions/Resource/Topic/Review.ts
@@ -0,0 +1,70 @@
/* eslint-disable @typescript-eslint/camelcase */

import { ObjectDefinitionBlock } from 'nexus/dist/core'
import { Prisma } from '@prisma/client'
import { userSelect } from '../../User'
// import { companiesResolver } from '../resolvers/Resource'

export const reviews = (t: ObjectDefinitionBlock<'Query'>) => {
t.crud.bani684SiteContents({
alias: 'reviews',
description: 'Обзоры заведений',
type: 'Review',
ordering: true,
filtering: true,
// resolve: companiesResolver,
resolve(_, args, ctx) {
const variables = args as Pick<
Prisma.bani684_site_contentFindManyArgs,
'where'
>

const { deleted = false, published = true, hidemenu = false } =
variables.where || {}

return ctx.prisma.bani684_site_content.findMany({
...variables,
where: {
AND: [
{
template: 28,
deleted,
published,
hidemenu,
},
{
...variables.where,
},
],
},
select: {
id: true,
pagetitle: true,
longtitle: true,
description: true,
alias: true,
uri: true,
content: true,
published: true,
createdby: true,
createdon: true,
editedby: true,
editedon: true,
template: true,
searchable: true,
TemplateVarValues: {
select: {
id: true,
contentid: true,
tmplvarid: true,
value: true,
},
},
CreatedBy: {
select: userSelect,
},
},
})
},
})
}

0 comments on commit 8de6e94

Please sign in to comment.