-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix GraphQL schema localization. #17041
Fix GraphQL schema localization. #17041
Conversation
This pull request has merge conflicts. Please resolve those before requesting a review. |
Fix conflict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gvkries some minor suggestion
src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/Services/SchemaService.cs
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/Views/Admin/Index.cshtml
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Lists/GraphQL/ContainedInputObjectType.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Media/GraphQL/MediaAssetObjectType.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Queries/Sql/GraphQL/SqlQueryFieldTypeProvider.cs
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.Apis.GraphQL.Abstractions/Queries/WhereInputObjectGraphType.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.Apis.GraphQL.Abstractions/Queries/WhereInputObjectGraphType.cs
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/Types/ContentItemWhereInput.cs
Outdated
Show resolved
Hide resolved
...rdCore/OrchardCore.ContentManagement.GraphQL/Queries/Types/DynamicPartWhereInputGraphType.cs
Outdated
Show resolved
Hide resolved
test/OrchardCore.Tests/Apis/GraphQL/ContentItemsFieldTypeTests.cs
Outdated
Show resolved
Hide resolved
…utObjectType.cs Co-authored-by: Mike Alhayek <[email protected]>
…jectType.cs Co-authored-by: Mike Alhayek <[email protected]>
…ryFieldTypeProvider.cs Co-authored-by: Mike Alhayek <[email protected]>
…QL/ElasticQueryFieldTypeProvider.cs Co-authored-by: Mike Alhayek <[email protected]>
…Types/ContentItemWhereInput.cs Co-authored-by: Mike Alhayek <[email protected]>
…ries/OrchardCore into gvkries/graphql-localization
…neQueryFieldTypeProvider.cs Co-authored-by: Mike Alhayek <[email protected]>
src/OrchardCore.Modules/OrchardCore.ContentFields/GraphQL/Fields/ContentFieldsProvider.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.Apis.GraphQL.Abstractions/Queries/WhereInputObjectGraphType.cs
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/ContentItemsFieldType.cs
Outdated
Show resolved
Hide resolved
…ds/ContentFieldsProvider.cs Co-authored-by: Mike Alhayek <[email protected]>
…ContentItemsFieldType.cs Co-authored-by: Mike Alhayek <[email protected]>
Field<StringGraphType>("fileName").Description(S["the file name of the media file item"]).Resolve(x => x.Source.FileName); | ||
Field<StringGraphType>("path").Description(S["the path of the media file item"]).Resolve(x => x.Source.Path); | ||
Field<StringGraphType>("url").Description(S["the url name of the media file item"]).Resolve(x => x.Source.Url); | ||
Field<StringGraphType>("mediaText").Description(S["the media text of the file item"]).Resolve(x => x.Source.MediaText); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Field<StringGraphType>("fileName").Description(S["the file name of the media file item"]).Resolve(x => x.Source.FileName); | |
Field<StringGraphType>("path").Description(S["the path of the media file item"]).Resolve(x => x.Source.Path); | |
Field<StringGraphType>("url").Description(S["the url name of the media file item"]).Resolve(x => x.Source.Url); | |
Field<StringGraphType>("mediaText").Description(S["the media text of the file item"]).Resolve(x => x.Source.MediaText); | |
Field<StringGraphType>("fileName").Description(S["the file name of the media file item"]).Resolve(x => x.Source.FileName); | |
Field<StringGraphType>("path") | |
.Description(S["the path of the media file item"]) | |
.Resolve(x => x.Source.Path); | |
Field<StringGraphType>("url") | |
.Description(S["the url name of the media file item"]) | |
.Resolve(x => x.Source.Url); | |
Field<StringGraphType>("mediaText") | |
.Description(S["the media text of the file item"]) | |
.Resolve(x => x.Source.MediaText); |
Very well done. You navigated most of the pitfalls of localization we can have in OC. |
With the help of @MikeAlhayek 🤗 |
The GraphQL schema is cached the first time it is being build and only one instance and language is being cached at all. This means that the schema language depends on the first request and does not reflect the currents user language at all.
I have now added a per-culture cache of the schema.
Additionally, parts of the schema are not localized at all. You may end up with a mixture of different languages in the schema. I added localization to different parts of the schema, to make this more complete.
Fixes #2765.