Skip to content

Commit

Permalink
Merge pull request #398 from NDLANO/add-feide-groups
Browse files Browse the repository at this point in the history
Add feide groups
  • Loading branch information
gunnarvelle authored Nov 29, 2023
2 parents 6f3ac9b + 78e70d2 commit 13731e5
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 20 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
"@graphql-codegen/typescript-operations": "^2.5.6",
"@graphql-codegen/typescript-resolvers": "^2.7.6",
"@graphql-eslint/eslint-plugin": "^3.12.0",
"@ndla/types-backend": "^0.2.29",
"@ndla/types-backend": "^0.2.30",
"@ndla/types-embed": "^4.0.7",
"@ndla/types-taxonomy": "^1.0.19",
"@ndla/types-taxonomy": "^1.0.21",
"@types/bunyan": "^1.8.5",
"@types/compression": "^1.7.2",
"@types/cors": "^2.8.4",
Expand Down
18 changes: 12 additions & 6 deletions src/api/folderApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,18 @@ export async function deletePersonalData(context: Context): Promise<boolean> {
}
}

export async function getPersonalData(context: Context): Promise<IMyNDLAUser> {
const response = await fetch(`/learningpath-api/v1/users/`, {
...context,
shouldUseCache: false,
});
return await resolveJson(response);
export async function getPersonalData(
context: Context,
): Promise<IMyNDLAUser | undefined> {
try {
const response = await fetch(`/learningpath-api/v1/users/`, {
...context,
shouldUseCache: false,
});
return await resolveJson(response);
} catch (e) {
return undefined;
}
}

export async function patchPersonalData(
Expand Down
2 changes: 1 addition & 1 deletion src/resolvers/folderResolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const Query: Pick<
__: any,
context: ContextWithLoaders,
): Promise<GQLMyNdlaPersonalData> {
return getPersonalData(context);
return (getPersonalData(context) as unknown) as GQLMyNdlaPersonalData;
},
};

Expand Down
14 changes: 13 additions & 1 deletion src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1140,13 +1140,25 @@ export const typeDefs = gql`
parentId: String
}
type MyNdlaGroup {
id: String!
displayName: String!
isPrimarySchool: Boolean!
parentId: String
}
type MyNdlaPersonalData {
id: Int!
feideId: String!
username: String!
email: String!
displayName: String!
favoriteSubjects: [String!]!
role: String!
arenaEnabled: Boolean!
shareName: Boolean!
organization: String!
groups: [MyNdlaGroup!]!
}
type ConfigMetaBoolean {
Expand Down Expand Up @@ -1368,7 +1380,7 @@ export const typeDefs = gql`
includeResources: Boolean
): SharedFolder!
allFolderResources(size: Int): [FolderResource!]!
personalData: MyNdlaPersonalData!
personalData: MyNdlaPersonalData
image(id: String!): ImageMetaInformationV2
examLockStatus: ConfigMetaBoolean!
aiEnabledOrgs: ConfigMetaStringList
Expand Down
33 changes: 31 additions & 2 deletions src/types/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1010,14 +1010,27 @@ export type GQLMutationUpdatePersonalDataArgs = {
shareName?: InputMaybe<Scalars['Boolean']>;
};

export type GQLMyNdlaGroup = {
__typename?: 'MyNdlaGroup';
displayName: Scalars['String'];
id: Scalars['String'];
isPrimarySchool: Scalars['Boolean'];
parentId?: Maybe<Scalars['String']>;
};

export type GQLMyNdlaPersonalData = {
__typename?: 'MyNdlaPersonalData';
arenaEnabled: Scalars['Boolean'];
displayName: Scalars['String'];
email: Scalars['String'];
favoriteSubjects: Array<Scalars['String']>;
feideId: Scalars['String'];
groups: Array<GQLMyNdlaGroup>;
id: Scalars['Int'];
organization: Scalars['String'];
role: Scalars['String'];
shareName: Scalars['Boolean'];
username: Scalars['String'];
};

export type GQLName = {
Expand Down Expand Up @@ -1162,7 +1175,7 @@ export type GQLQuery = {
image?: Maybe<GQLImageMetaInformationV2>;
learningpath?: Maybe<GQLLearningpath>;
listingPage?: Maybe<GQLListingPage>;
personalData: GQLMyNdlaPersonalData;
personalData?: Maybe<GQLMyNdlaPersonalData>;
podcastSearch?: Maybe<GQLAudioSearch>;
podcastSeries?: Maybe<GQLPodcastSeriesWithEpisodes>;
podcastSeriesSearch?: Maybe<GQLPodcastSeriesSearch>;
Expand Down Expand Up @@ -2016,6 +2029,7 @@ export type GQLResolversTypes = {
MovieResourceTypes: ResolverTypeWrapper<GQLMovieResourceTypes>;
MovieTheme: ResolverTypeWrapper<GQLMovieTheme>;
Mutation: ResolverTypeWrapper<{}>;
MyNdlaGroup: ResolverTypeWrapper<GQLMyNdlaGroup>;
MyNdlaPersonalData: ResolverTypeWrapper<GQLMyNdlaPersonalData>;
Name: ResolverTypeWrapper<GQLName>;
NewFolder: ResolverTypeWrapper<GQLNewFolder>;
Expand Down Expand Up @@ -2167,6 +2181,7 @@ export type GQLResolversParentTypes = {
MovieResourceTypes: GQLMovieResourceTypes;
MovieTheme: GQLMovieTheme;
Mutation: {};
MyNdlaGroup: GQLMyNdlaGroup;
MyNdlaPersonalData: GQLMyNdlaPersonalData;
Name: GQLName;
NewFolder: GQLNewFolder;
Expand Down Expand Up @@ -3108,13 +3123,26 @@ export type GQLMutationResolvers<ContextType = any, ParentType extends GQLResolv
updatePersonalData?: Resolver<GQLResolversTypes['MyNdlaPersonalData'], ParentType, ContextType, Partial<GQLMutationUpdatePersonalDataArgs>>;
};

export type GQLMyNdlaGroupResolvers<ContextType = any, ParentType extends GQLResolversParentTypes['MyNdlaGroup'] = GQLResolversParentTypes['MyNdlaGroup']> = {
displayName?: Resolver<GQLResolversTypes['String'], ParentType, ContextType>;
id?: Resolver<GQLResolversTypes['String'], ParentType, ContextType>;
isPrimarySchool?: Resolver<GQLResolversTypes['Boolean'], ParentType, ContextType>;
parentId?: Resolver<Maybe<GQLResolversTypes['String']>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};

export type GQLMyNdlaPersonalDataResolvers<ContextType = any, ParentType extends GQLResolversParentTypes['MyNdlaPersonalData'] = GQLResolversParentTypes['MyNdlaPersonalData']> = {
arenaEnabled?: Resolver<GQLResolversTypes['Boolean'], ParentType, ContextType>;
displayName?: Resolver<GQLResolversTypes['String'], ParentType, ContextType>;
email?: Resolver<GQLResolversTypes['String'], ParentType, ContextType>;
favoriteSubjects?: Resolver<Array<GQLResolversTypes['String']>, ParentType, ContextType>;
feideId?: Resolver<GQLResolversTypes['String'], ParentType, ContextType>;
groups?: Resolver<Array<GQLResolversTypes['MyNdlaGroup']>, ParentType, ContextType>;
id?: Resolver<GQLResolversTypes['Int'], ParentType, ContextType>;
organization?: Resolver<GQLResolversTypes['String'], ParentType, ContextType>;
role?: Resolver<GQLResolversTypes['String'], ParentType, ContextType>;
shareName?: Resolver<GQLResolversTypes['Boolean'], ParentType, ContextType>;
username?: Resolver<GQLResolversTypes['String'], ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};

Expand Down Expand Up @@ -3260,7 +3288,7 @@ export type GQLQueryResolvers<ContextType = any, ParentType extends GQLResolvers
image?: Resolver<Maybe<GQLResolversTypes['ImageMetaInformationV2']>, ParentType, ContextType, RequireFields<GQLQueryImageArgs, 'id'>>;
learningpath?: Resolver<Maybe<GQLResolversTypes['Learningpath']>, ParentType, ContextType, RequireFields<GQLQueryLearningpathArgs, 'pathId'>>;
listingPage?: Resolver<Maybe<GQLResolversTypes['ListingPage']>, ParentType, ContextType, Partial<GQLQueryListingPageArgs>>;
personalData?: Resolver<GQLResolversTypes['MyNdlaPersonalData'], ParentType, ContextType>;
personalData?: Resolver<Maybe<GQLResolversTypes['MyNdlaPersonalData']>, ParentType, ContextType>;
podcastSearch?: Resolver<Maybe<GQLResolversTypes['AudioSearch']>, ParentType, ContextType, RequireFields<GQLQueryPodcastSearchArgs, 'page' | 'pageSize'>>;
podcastSeries?: Resolver<Maybe<GQLResolversTypes['PodcastSeriesWithEpisodes']>, ParentType, ContextType, RequireFields<GQLQueryPodcastSeriesArgs, 'id'>>;
podcastSeriesSearch?: Resolver<Maybe<GQLResolversTypes['PodcastSeriesSearch']>, ParentType, ContextType, RequireFields<GQLQueryPodcastSeriesSearchArgs, 'page' | 'pageSize'>>;
Expand Down Expand Up @@ -3742,6 +3770,7 @@ export type GQLResolvers<ContextType = any> = {
MovieResourceTypes?: GQLMovieResourceTypesResolvers<ContextType>;
MovieTheme?: GQLMovieThemeResolvers<ContextType>;
Mutation?: GQLMutationResolvers<ContextType>;
MyNdlaGroup?: GQLMyNdlaGroupResolvers<ContextType>;
MyNdlaPersonalData?: GQLMyNdlaPersonalDataResolvers<ContextType>;
Name?: GQLNameResolvers<ContextType>;
NewFolder?: GQLNewFolderResolvers<ContextType>;
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1506,20 +1506,20 @@
resolved "https://registry.yarnpkg.com/@ndla/licenses/-/licenses-7.2.2.tgz#5b165694638acac7a431266b9ece3751a6497578"
integrity sha512-DGMdoa/5QGdnZcOLLL3tbC95dEc+YWhjavtj6aRoeCbl4vsTX1nzMY4ZsdbiDxtZsnlcASouvG5ffYTbCW3s0Q==

"@ndla/types-backend@^0.2.29":
version "0.2.29"
resolved "https://registry.yarnpkg.com/@ndla/types-backend/-/types-backend-0.2.29.tgz#0c6b611f701b077bb427297395069959a6bbda23"
integrity sha512-VkPoyNMi9wLHZb8ikHCdYKz7xc3TbNqHqvz9/lgjlL+pTZCSsvXpPnix/E3FnZGf9jq+SCfZGqkbvBJR4e2gQA==
"@ndla/types-backend@^0.2.30":
version "0.2.30"
resolved "https://registry.yarnpkg.com/@ndla/types-backend/-/types-backend-0.2.30.tgz#048d8f7a292602f3cf1852c29c6e3f8187c48da3"
integrity sha512-lJStzANa90o5INue8TlCKzw9e/b0bgeD5vs4zDii+3rAnfIogTd5jBQEqsyqbfu+MynJdYG+oBVx5EZMZjNStg==

"@ndla/types-embed@^4.0.7":
version "4.0.7"
resolved "https://registry.yarnpkg.com/@ndla/types-embed/-/types-embed-4.0.7.tgz#6dd6d4eb17db22e8ee6d4182888cd18fef29624d"
integrity sha512-PduZNoLAegJk8DnseqYzZ0+P3J20ol4lx1qcMlgn61YbWHwRC8oEKkL85zHkv+EkqCf8tRgJfVG5YcTh+jfBzQ==

"@ndla/types-taxonomy@^1.0.19":
version "1.0.19"
resolved "https://registry.yarnpkg.com/@ndla/types-taxonomy/-/types-taxonomy-1.0.19.tgz#9fdfd8a5934a9108421f0b30f8f4a135a5fa7642"
integrity sha512-F0rN7OWD7iUnJv8F/R9ZMW5Zu1ZjEd9pXHxO/BsiaxqaJWXT8b4TQtF0pUQ17pEXZkZlr156+hyfx3bQTw8+iw==
"@ndla/types-taxonomy@^1.0.21":
version "1.0.21"
resolved "https://registry.yarnpkg.com/@ndla/types-taxonomy/-/types-taxonomy-1.0.21.tgz#fe3db31cbd859385fa21b27ade81f98a6d314200"
integrity sha512-80QnSj1cg0vgX001W13Sl/VJTreTWNFx5uC5ZJcDGJNbU+dK1fQ8zRUkNa46od61+JjX6ZNWYBqpVCOb0urexQ==

"@nicolo-ribaudo/[email protected]":
version "5.1.1-v1"
Expand Down

0 comments on commit 13731e5

Please sign in to comment.