Skip to content
This repository was archived by the owner on Aug 25, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
publishPackages: ${{ env.publishPackages }}
steps:
- name: Checkout source code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Apply versioning
if: success()
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set Variables
run: |
if [[ $GITHUB_BASE_REF = 'develop' ]]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/createJiraIssue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- name: Checkout source code
if: ${{steps.checkPermission.outputs.require-result}} == true
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Create Jira Issue
id: createJiraIssue
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/createRelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
release_sha: ${{ env.release_sha }}
steps:
- name: Checkout source code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Apply versioning
if: success()
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
release_sha: ${{ needs.manageVariable.outputs.release_sha }}
steps:
- name: Checkout source code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build
if: success()
Expand All @@ -94,7 +94,7 @@ jobs:

- name: Upload packages to artifacts
if: success() && env.publishPackages == 'true'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Optimizely.Graph.Client-${{ env.packageVersion }}
path: ${{ github.workspace}}/artifacts/
Expand Down Expand Up @@ -129,7 +129,7 @@ jobs:
release_sha: ${{ needs.manageVariable.outputs.release_sha }}
steps:
- name: Checkout source code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Fetch all tags
run: |
Expand Down Expand Up @@ -163,7 +163,7 @@ jobs:
New-Item -Path "artifacts" -ItemType Directory

- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: Optimizely.Graph.Client-${{ env.packageVersion }}
path: artifacts
Expand Down Expand Up @@ -198,7 +198,7 @@ jobs:
release_sha: ${{ needs.manageVariable.outputs.release_sha }}
steps:
- name: Checkout source code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Check tag exist
uses: mukunku/[email protected]
Expand Down Expand Up @@ -247,7 +247,7 @@ jobs:
New-Item -Path "artifacts" -ItemType Directory

- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: Optimizely.Graph.Client-${{ env.packageVersion }}
path: artifacts
Expand Down
13 changes: 1 addition & 12 deletions .github/workflows/intergrationTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,7 @@ jobs:
runs-on: windows-latest
steps:
- name: Checkout current branch
uses: actions/checkout@v3

- name: Replace settings variables
if: success()
uses: microsoft/variable-substitution@v1
with:
files: 'APIs/src/Testing/EPiServer.ContentGraph.IntegrationTests/appsettings.json'
env:
Optimizely.ContentGraph.GatewayAddress: ${{ secrets.GATEWAYADDRESS }}
Optimizely.ContentGraph.AppKey: ${{ secrets.APPKEY }}
Optimizely.ContentGraph.Secret: ${{ secrets.SECRET }}
Optimizely.ContentGraph.SingleKey: ${{ secrets.SINGLEKEY }}
uses: actions/checkout@v4

- name: Setup test environment
if: success()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unitTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: windows-latest
steps:
- name: Checkout current branch
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build and run tests
if: success()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ public virtual BaseTypeQueryBuilder Field(string propertyName)
if (!propertyName.IsNullOrEmpty())
{
string clonedPropName = ConvertNestedFieldToString.ConvertNestedFieldForQuery(propertyName);
graphObject.SelectItems.Append(
graphObject.SelectItems.Length == 0 ?
$"{clonedPropName}" :
$" {clonedPropName}"
);
AppendItem(clonedPropName);
}

return this;
Expand All @@ -72,11 +68,7 @@ public virtual BaseTypeQueryBuilder Field(string propertyName, string alias)
if (!propertyName.IsNullOrEmpty() && !alias.IsNullOrEmpty())
{
string clonedPropName = ConvertNestedFieldToString.ConvertNestedFieldForQuery(propertyName);
graphObject.SelectItems.Append(
graphObject.SelectItems.Length == 0 ?
$"{alias}:{clonedPropName}" :
$" {alias}:{clonedPropName}"
);
AppendItem($"{alias}:{clonedPropName}");
}
else
{
Expand All @@ -97,11 +89,7 @@ public virtual BaseTypeQueryBuilder Field(string propertyName, HighLightOptions
return this;
}
string clonedPropName = ConvertNestedFieldToString.ConvertNestedFieldForQuery(propertyName);
graphObject.SelectItems.Append(
graphObject.SelectItems.Length == 0 ?
$"{clonedPropName}{highLightOptions.Query}" :
$" {clonedPropName}{highLightOptions.Query}"
);
AppendItem($"{clonedPropName}{highLightOptions.Query}");
}

return this;
Expand All @@ -119,17 +107,9 @@ public virtual BaseTypeQueryBuilder Link(ITypeQueryBuilder link)
{
if (!linkQueryBuilder.GetLinkType().IsNullOrEmpty())
{
graphObject.SelectItems.Append(
graphObject.SelectItems.Length == 0 ?
$"_link(type:{linkQueryBuilder.GetLinkType()})" :
$" _link(type:{linkQueryBuilder.GetLinkType()})"
);
AppendItem($"_link(type:{linkQueryBuilder.GetLinkType()})");
}
graphObject.SelectItems.Append(
graphObject.SelectItems.Length == 0 ?
$"{{{linkQuery}}}" :
$" {{{linkQuery}}}"
);
AppendItem($"{{{linkQuery}}}");
}
return this;
}
Expand All @@ -152,27 +132,15 @@ public virtual BaseTypeQueryBuilder Link(ITypeQueryBuilder link, string alias)
{
if (string.IsNullOrEmpty(alias))
{
graphObject.SelectItems.Append(
graphObject.SelectItems.Length == 0 ?
$"_link(type:{linkQueryBuilder.GetLinkType()})" :
$" _link(type:{linkQueryBuilder.GetLinkType()})"
);
AppendItem($"_link(type:{linkQueryBuilder.GetLinkType()})");
}
else
{
graphObject.SelectItems.Append(
graphObject.SelectItems.Length == 0 ?
$"{alias}:_link(type:{linkQueryBuilder.GetLinkType()})" :
$" {alias}:_link(type:{linkQueryBuilder.GetLinkType()})"
);
AppendItem($"{alias}:_link(type:{linkQueryBuilder.GetLinkType()})");
}

}
graphObject.SelectItems.Append(
graphObject.SelectItems.Length == 0 ?
$"{{{linkQuery}}}" :
$" {{{linkQuery}}}"
);
AppendItem($"{{{linkQuery}}}");

}
return this;
Expand All @@ -184,11 +152,7 @@ public virtual BaseTypeQueryBuilder Children(ITypeQueryBuilder children)
string childrenItems = children.GetQuery()?.Query ?? string.Empty;
if (!childrenItems.IsNullOrEmpty())
{
graphObject.SelectItems.Append(
graphObject.SelectItems.Length == 0 ?
$"_children{{{childrenItems}}}" :
$" _children{{{childrenItems}}}"
);
AppendItem($"_children{{{childrenItems}}}");
}

return this;
Expand All @@ -203,13 +167,27 @@ public virtual BaseTypeQueryBuilder AddFragments(params FragmentBuilder[] fragme
return this;
}
protected virtual BaseTypeQueryBuilder AddFragment(FragmentBuilder fragment)
{
AddFragment(null, fragment);
return this;
}
public virtual BaseTypeQueryBuilder AddFragment(string fieldPath, FragmentBuilder fragment)
{
fragment.ValidateNotNullArgument("fragment");
graphObject.SelectItems.Append(
graphObject.SelectItems.Length == 0 ?
$"...{fragment.GetName()}" :
$" ...{fragment.GetName()}"
);
string propName;
if (fieldPath.IsNullOrEmpty())
{
propName = $"...{fragment.GetName()}";
}
else
{
var newPath = $"{fieldPath}.$$${fragment.GetName()}";
//trick: fragment init by $$$ then replace by dots ...
propName = ConvertNestedFieldToString.ConvertNestedFieldForQuery(newPath);
propName = propName.Replace("$", ".");
}

AppendItem(propName);

if (Parent != null)
{
Expand Down Expand Up @@ -239,5 +217,13 @@ private IEnumerable<FragmentBuilder> GetAllChildren(FragmentBuilder fragment)
}
}
}

protected virtual void AppendItem(string item)
{
if (!item.IsNullOrEmpty())
{
graphObject.SelectItems.Append(graphObject.SelectItems.Length > 0 ? $" {item}": item);
}
}
}
}
35 changes: 23 additions & 12 deletions APIs/src/EpiServer.ContentGraph/Api/Querying/FragmentBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ public override FragmentBuilder AddFragments(params FragmentBuilder[] fragments)
}
return this;
}
public FragmentBuilder AddFragment(string path, FragmentBuilder fragment)
{
if (_childrenFragments.IsNull())
{
_childrenFragments = new List<FragmentBuilder>();
}
base.AddFragment(path, fragment);
_childrenFragments.Add(fragment);

return this;
}
}

public class FragmentBuilder<T> : FragmentBuilder
Expand Down Expand Up @@ -112,10 +123,7 @@ private FragmentBuilder Recursive<TSub>(params Recursion[] recursives) where TSu
}

string subTypeName = typeof(TSub).Name;
graphObject.SelectItems.Append(graphObject.SelectItems.Length == 0 ?
$"... on {subTypeName}{{{recursiveNess}}}" :
$" ... on {subTypeName}{{{recursiveNess}}}"
);
AppendItem($"... on {subTypeName}{{{recursiveNess}}}");
return this;
}
private FragmentBuilder<T> Recursive<TSub>(string fieldName, int? depth = null) where TSub : T
Expand Down Expand Up @@ -154,10 +162,7 @@ public FragmentBuilder<T> Inline<TSub>(params string[] fields)
propertyBuilder.Append(ConvertNestedFieldToString.ConvertNestedFieldForQuery(field));
}
string subTypeName = typeof(TSub).Name;
graphObject.SelectItems.Append(graphObject.SelectItems.Length == 0 ?
$"... on {subTypeName}{{{propertyBuilder}}}" :
$" ... on {subTypeName}{{{propertyBuilder}}}"
);
AppendItem($"... on {subTypeName}{{{propertyBuilder}}}");
return this;
}
/// <summary>
Expand All @@ -179,10 +184,7 @@ public FragmentBuilder<T> Inline<TSub>(params Expression<Func<TSub, object>>[] f
propertyBuilder.Append(ConvertNestedFieldToString.ConvertNestedFieldForQuery(fieldSelector.GetFieldPath()));
}
string subTypeName = typeof(TSub).Name;
graphObject.SelectItems.Append(graphObject.SelectItems.Length == 0 ?
$"... on {subTypeName}{{{propertyBuilder}}}" :
$" ... on {subTypeName}{{{propertyBuilder}}}"
);
AppendItem($"... on {subTypeName}{{{propertyBuilder}}}");
return this;
}
/// <summary>
Expand All @@ -198,6 +200,15 @@ public FragmentBuilder<T> Inline<TSub>(params Expression<Func<TSub, Recursion>>[
Recursive<TSub>(fieldSelectors.Select(selector => paser.GetReturnType(selector)).ToArray());
return this;
}
public FragmentBuilder<T> AddFragment<TProp>(Expression<Func<T, TProp>> fieldSelector, FragmentBuilder<TProp> fragment)
{
fieldSelector.ValidateNotNullArgument(nameof(fieldSelector));
fragment.ValidateNotNullArgument(nameof(fragment));

var fieldPath = fieldSelector.GetFieldPath();
base.AddFragment(fieldPath, fragment);
return this;
}
public override GraphQLRequest GetQuery()
{
_query.Query = $"fragment {_query.OperationName} on {typeof(T).Name} {graphObject}";
Expand Down
Loading
Loading