add featureList to the User type which contains a list of feature type
This commit is contained in:
@ -3696,6 +3696,7 @@ export enum UploadImportFileType {
|
||||
export type User = {
|
||||
__typename?: 'User';
|
||||
email?: Maybe<Scalars['String']>;
|
||||
featureList?: Maybe<Array<Maybe<Feature>>>;
|
||||
features?: Maybe<Array<Maybe<Scalars['String']>>>;
|
||||
followersCount?: Maybe<Scalars['Int']>;
|
||||
friendsCount?: Maybe<Scalars['Int']>;
|
||||
@ -7139,6 +7140,7 @@ export type UploadImportFileSuccessResolvers<ContextType = ResolverContext, Pare
|
||||
|
||||
export type UserResolvers<ContextType = ResolverContext, ParentType extends ResolversParentTypes['User'] = ResolversParentTypes['User']> = {
|
||||
email?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
|
||||
featureList?: Resolver<Maybe<Array<Maybe<ResolversTypes['Feature']>>>, ParentType, ContextType>;
|
||||
features?: Resolver<Maybe<Array<Maybe<ResolversTypes['String']>>>, ParentType, ContextType>;
|
||||
followersCount?: Resolver<Maybe<ResolversTypes['Int']>, ParentType, ContextType>;
|
||||
friendsCount?: Resolver<Maybe<ResolversTypes['Int']>, ParentType, ContextType>;
|
||||
|
||||
@ -2984,6 +2984,7 @@ enum UploadImportFileType {
|
||||
|
||||
type User {
|
||||
email: String
|
||||
featureList: [Feature]
|
||||
features: [String]
|
||||
followersCount: Int
|
||||
friendsCount: Int
|
||||
|
||||
@ -376,7 +376,18 @@ export const functionResolvers = {
|
||||
if (!ctx.claims?.uid) {
|
||||
return undefined
|
||||
}
|
||||
return findUserFeatures(ctx.claims.uid)
|
||||
const userFeatures = await findUserFeatures(ctx.claims.uid)
|
||||
return userFeatures.map((feature) => feature.name)
|
||||
},
|
||||
async featureList(
|
||||
_: User,
|
||||
__: Record<string, unknown>,
|
||||
ctx: WithDataSourcesContext
|
||||
) {
|
||||
if (!ctx.uid) {
|
||||
return undefined
|
||||
}
|
||||
return findUserFeatures(ctx.uid)
|
||||
},
|
||||
},
|
||||
Article: {
|
||||
|
||||
@ -89,6 +89,7 @@ const schema = gql`
|
||||
source: String
|
||||
intercomHash: String
|
||||
features: [String]
|
||||
featureList: [Feature]
|
||||
}
|
||||
|
||||
type Profile {
|
||||
|
||||
@ -122,14 +122,12 @@ export const signFeatureToken = (
|
||||
)
|
||||
}
|
||||
|
||||
export const findUserFeatures = async (userId: string): Promise<string[]> => {
|
||||
return (
|
||||
await getRepository(Feature).find({
|
||||
where: {
|
||||
user: { id: userId },
|
||||
},
|
||||
})
|
||||
).map((feature) => feature.name)
|
||||
export const findUserFeatures = async (userId: string) => {
|
||||
return getRepository(Feature).find({
|
||||
where: {
|
||||
user: { id: userId },
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export const findGrantedFeatureByName = async (
|
||||
|
||||
Reference in New Issue
Block a user