How to generate dynamic path value for a graphql query response using GraphQL.NET?
I have REST API (api/tax/v1/countries) with the following response. In the below the pngimagePath and svgimagePath properties are pointing to the image type endpoints(api/tax/v1/country/Country1/{FlagPNG or FlagSVG})
The paths are generated dynamically in this case.
{
"countries": [
{
"pngimagePath": "https://test.com/api/tax/v1/country/Country1/4/image/FlagPNG",
"svgimagePath": "https://test.com/api/tax/v1/country/Country1/405/image/FlagSVG",
"displayName": "Country1",
"displayNameShort": "Country1",
"providerName": "Testing",
"providerTerms": null,
"uuid": "1",
"name": "Country1",
"path": "Country1",
"completeResponse": true
},
{
"pngimagePath": "https://test.com/api/tax/v1/country/Country2/5/image/FlagPNG",
"svgimagePath": "https://test.com/api/tax/v1/country/Country2/406/image/FlagSVG",
"displayName": "Country2",
"displayNameShort": "Country2",
"providerName": "Testing one",
"providerTerms": null,
"uuid": "2",
"name": "Country2",
"path": "Country2",
"completeResponse": true
}
],
"authorised": false,
"userMessage": ""
}
// Code to generate the image path
var apiPath = _appSettings.Value.ApiPath + "country/";
result.Countries.AddRange(rawCountries.Select(country => new DTO.CountryDTO {
PNGImagePath = $"{apiPath}{Helper.ReplaceChars(country.DefaultDisplayName)}/{country.PngImageId}/image/{country.PngImageType}" , SVGImagePath = $"{apiPath}{Helper.ReplaceChars(country.DefaultDisplayName)}/{country.SvgImageId}/image/{country.SvgImageType}" , } ) ) ;
I want to generate the image path using GraphQL.NET.
Can anyone help me to know how to implement this feature
c# asp.net-core-2.0 graphql-dotnet
add a comment |
I have REST API (api/tax/v1/countries) with the following response. In the below the pngimagePath and svgimagePath properties are pointing to the image type endpoints(api/tax/v1/country/Country1/{FlagPNG or FlagSVG})
The paths are generated dynamically in this case.
{
"countries": [
{
"pngimagePath": "https://test.com/api/tax/v1/country/Country1/4/image/FlagPNG",
"svgimagePath": "https://test.com/api/tax/v1/country/Country1/405/image/FlagSVG",
"displayName": "Country1",
"displayNameShort": "Country1",
"providerName": "Testing",
"providerTerms": null,
"uuid": "1",
"name": "Country1",
"path": "Country1",
"completeResponse": true
},
{
"pngimagePath": "https://test.com/api/tax/v1/country/Country2/5/image/FlagPNG",
"svgimagePath": "https://test.com/api/tax/v1/country/Country2/406/image/FlagSVG",
"displayName": "Country2",
"displayNameShort": "Country2",
"providerName": "Testing one",
"providerTerms": null,
"uuid": "2",
"name": "Country2",
"path": "Country2",
"completeResponse": true
}
],
"authorised": false,
"userMessage": ""
}
// Code to generate the image path
var apiPath = _appSettings.Value.ApiPath + "country/";
result.Countries.AddRange(rawCountries.Select(country => new DTO.CountryDTO {
PNGImagePath = $"{apiPath}{Helper.ReplaceChars(country.DefaultDisplayName)}/{country.PngImageId}/image/{country.PngImageType}" , SVGImagePath = $"{apiPath}{Helper.ReplaceChars(country.DefaultDisplayName)}/{country.SvgImageId}/image/{country.SvgImageType}" , } ) ) ;
I want to generate the image path using GraphQL.NET.
Can anyone help me to know how to implement this feature
c# asp.net-core-2.0 graphql-dotnet
What do you mean by generate image path? Doesapi/tax/v1/countries
callGraphQL.NET
? Have you usedGraphQL.NET
or you want to migrate web api to it?
– Tao Zhou
Nov 28 '18 at 2:14
I am in the process of migrating the existing REST APIs to GraphQL endpoint using GraphQL.NET. In the existing response as mentioned in my query there is "pngimagePath": "test.com/api/tax/v1/country/Country1/4/image/FlagPNG" and "svgimagePath": "test.com/api/tax/v1/country/Country1/405/image/FlagSVG". As part of the graphql response for this query I also need to expose these properties also. Can you please help me to know how to accomplish this implementation
– santosh kumar patro
Nov 28 '18 at 7:02
add a comment |
I have REST API (api/tax/v1/countries) with the following response. In the below the pngimagePath and svgimagePath properties are pointing to the image type endpoints(api/tax/v1/country/Country1/{FlagPNG or FlagSVG})
The paths are generated dynamically in this case.
{
"countries": [
{
"pngimagePath": "https://test.com/api/tax/v1/country/Country1/4/image/FlagPNG",
"svgimagePath": "https://test.com/api/tax/v1/country/Country1/405/image/FlagSVG",
"displayName": "Country1",
"displayNameShort": "Country1",
"providerName": "Testing",
"providerTerms": null,
"uuid": "1",
"name": "Country1",
"path": "Country1",
"completeResponse": true
},
{
"pngimagePath": "https://test.com/api/tax/v1/country/Country2/5/image/FlagPNG",
"svgimagePath": "https://test.com/api/tax/v1/country/Country2/406/image/FlagSVG",
"displayName": "Country2",
"displayNameShort": "Country2",
"providerName": "Testing one",
"providerTerms": null,
"uuid": "2",
"name": "Country2",
"path": "Country2",
"completeResponse": true
}
],
"authorised": false,
"userMessage": ""
}
// Code to generate the image path
var apiPath = _appSettings.Value.ApiPath + "country/";
result.Countries.AddRange(rawCountries.Select(country => new DTO.CountryDTO {
PNGImagePath = $"{apiPath}{Helper.ReplaceChars(country.DefaultDisplayName)}/{country.PngImageId}/image/{country.PngImageType}" , SVGImagePath = $"{apiPath}{Helper.ReplaceChars(country.DefaultDisplayName)}/{country.SvgImageId}/image/{country.SvgImageType}" , } ) ) ;
I want to generate the image path using GraphQL.NET.
Can anyone help me to know how to implement this feature
c# asp.net-core-2.0 graphql-dotnet
I have REST API (api/tax/v1/countries) with the following response. In the below the pngimagePath and svgimagePath properties are pointing to the image type endpoints(api/tax/v1/country/Country1/{FlagPNG or FlagSVG})
The paths are generated dynamically in this case.
{
"countries": [
{
"pngimagePath": "https://test.com/api/tax/v1/country/Country1/4/image/FlagPNG",
"svgimagePath": "https://test.com/api/tax/v1/country/Country1/405/image/FlagSVG",
"displayName": "Country1",
"displayNameShort": "Country1",
"providerName": "Testing",
"providerTerms": null,
"uuid": "1",
"name": "Country1",
"path": "Country1",
"completeResponse": true
},
{
"pngimagePath": "https://test.com/api/tax/v1/country/Country2/5/image/FlagPNG",
"svgimagePath": "https://test.com/api/tax/v1/country/Country2/406/image/FlagSVG",
"displayName": "Country2",
"displayNameShort": "Country2",
"providerName": "Testing one",
"providerTerms": null,
"uuid": "2",
"name": "Country2",
"path": "Country2",
"completeResponse": true
}
],
"authorised": false,
"userMessage": ""
}
// Code to generate the image path
var apiPath = _appSettings.Value.ApiPath + "country/";
result.Countries.AddRange(rawCountries.Select(country => new DTO.CountryDTO {
PNGImagePath = $"{apiPath}{Helper.ReplaceChars(country.DefaultDisplayName)}/{country.PngImageId}/image/{country.PngImageType}" , SVGImagePath = $"{apiPath}{Helper.ReplaceChars(country.DefaultDisplayName)}/{country.SvgImageId}/image/{country.SvgImageType}" , } ) ) ;
I want to generate the image path using GraphQL.NET.
Can anyone help me to know how to implement this feature
c# asp.net-core-2.0 graphql-dotnet
c# asp.net-core-2.0 graphql-dotnet
asked Nov 27 '18 at 18:53
santosh kumar patrosantosh kumar patro
1,89682660
1,89682660
What do you mean by generate image path? Doesapi/tax/v1/countries
callGraphQL.NET
? Have you usedGraphQL.NET
or you want to migrate web api to it?
– Tao Zhou
Nov 28 '18 at 2:14
I am in the process of migrating the existing REST APIs to GraphQL endpoint using GraphQL.NET. In the existing response as mentioned in my query there is "pngimagePath": "test.com/api/tax/v1/country/Country1/4/image/FlagPNG" and "svgimagePath": "test.com/api/tax/v1/country/Country1/405/image/FlagSVG". As part of the graphql response for this query I also need to expose these properties also. Can you please help me to know how to accomplish this implementation
– santosh kumar patro
Nov 28 '18 at 7:02
add a comment |
What do you mean by generate image path? Doesapi/tax/v1/countries
callGraphQL.NET
? Have you usedGraphQL.NET
or you want to migrate web api to it?
– Tao Zhou
Nov 28 '18 at 2:14
I am in the process of migrating the existing REST APIs to GraphQL endpoint using GraphQL.NET. In the existing response as mentioned in my query there is "pngimagePath": "test.com/api/tax/v1/country/Country1/4/image/FlagPNG" and "svgimagePath": "test.com/api/tax/v1/country/Country1/405/image/FlagSVG". As part of the graphql response for this query I also need to expose these properties also. Can you please help me to know how to accomplish this implementation
– santosh kumar patro
Nov 28 '18 at 7:02
What do you mean by generate image path? Does
api/tax/v1/countries
call GraphQL.NET
? Have you used GraphQL.NET
or you want to migrate web api to it?– Tao Zhou
Nov 28 '18 at 2:14
What do you mean by generate image path? Does
api/tax/v1/countries
call GraphQL.NET
? Have you used GraphQL.NET
or you want to migrate web api to it?– Tao Zhou
Nov 28 '18 at 2:14
I am in the process of migrating the existing REST APIs to GraphQL endpoint using GraphQL.NET. In the existing response as mentioned in my query there is "pngimagePath": "test.com/api/tax/v1/country/Country1/4/image/FlagPNG" and "svgimagePath": "test.com/api/tax/v1/country/Country1/405/image/FlagSVG". As part of the graphql response for this query I also need to expose these properties also. Can you please help me to know how to accomplish this implementation
– santosh kumar patro
Nov 28 '18 at 7:02
I am in the process of migrating the existing REST APIs to GraphQL endpoint using GraphQL.NET. In the existing response as mentioned in my query there is "pngimagePath": "test.com/api/tax/v1/country/Country1/4/image/FlagPNG" and "svgimagePath": "test.com/api/tax/v1/country/Country1/405/image/FlagSVG". As part of the graphql response for this query I also need to expose these properties also. Can you please help me to know how to accomplish this implementation
– santosh kumar patro
Nov 28 '18 at 7:02
add a comment |
1 Answer
1
active
oldest
votes
For pngimagePath
which is generated based on country
, you could define a new field with resolve
to generate the value for pngimagePath
.
public class PlayerType : ObjectGraphType<Player>
{
public PlayerType(ISkaterStatisticRepository skaterStatisticRepository)
{
Field(x => x.Id);
Field(x => x.Name, true);
Field(x => x.BirthPlace);
Field(x => x.Height);
Field(x => x.WeightLbs);
Field<StringGraphType>("pngimagePath", resolve: context => $"{context.Source.Name} {context.Source.BirthDate} {context.Source.BirthPlace}");
}
}
Thanks much for your inputs :). It helped me a lot. I will implement it.
– santosh kumar patro
Nov 28 '18 at 7:50
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53506345%2fhow-to-generate-dynamic-path-value-for-a-graphql-query-response-using-graphql-ne%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
For pngimagePath
which is generated based on country
, you could define a new field with resolve
to generate the value for pngimagePath
.
public class PlayerType : ObjectGraphType<Player>
{
public PlayerType(ISkaterStatisticRepository skaterStatisticRepository)
{
Field(x => x.Id);
Field(x => x.Name, true);
Field(x => x.BirthPlace);
Field(x => x.Height);
Field(x => x.WeightLbs);
Field<StringGraphType>("pngimagePath", resolve: context => $"{context.Source.Name} {context.Source.BirthDate} {context.Source.BirthPlace}");
}
}
Thanks much for your inputs :). It helped me a lot. I will implement it.
– santosh kumar patro
Nov 28 '18 at 7:50
add a comment |
For pngimagePath
which is generated based on country
, you could define a new field with resolve
to generate the value for pngimagePath
.
public class PlayerType : ObjectGraphType<Player>
{
public PlayerType(ISkaterStatisticRepository skaterStatisticRepository)
{
Field(x => x.Id);
Field(x => x.Name, true);
Field(x => x.BirthPlace);
Field(x => x.Height);
Field(x => x.WeightLbs);
Field<StringGraphType>("pngimagePath", resolve: context => $"{context.Source.Name} {context.Source.BirthDate} {context.Source.BirthPlace}");
}
}
Thanks much for your inputs :). It helped me a lot. I will implement it.
– santosh kumar patro
Nov 28 '18 at 7:50
add a comment |
For pngimagePath
which is generated based on country
, you could define a new field with resolve
to generate the value for pngimagePath
.
public class PlayerType : ObjectGraphType<Player>
{
public PlayerType(ISkaterStatisticRepository skaterStatisticRepository)
{
Field(x => x.Id);
Field(x => x.Name, true);
Field(x => x.BirthPlace);
Field(x => x.Height);
Field(x => x.WeightLbs);
Field<StringGraphType>("pngimagePath", resolve: context => $"{context.Source.Name} {context.Source.BirthDate} {context.Source.BirthPlace}");
}
}
For pngimagePath
which is generated based on country
, you could define a new field with resolve
to generate the value for pngimagePath
.
public class PlayerType : ObjectGraphType<Player>
{
public PlayerType(ISkaterStatisticRepository skaterStatisticRepository)
{
Field(x => x.Id);
Field(x => x.Name, true);
Field(x => x.BirthPlace);
Field(x => x.Height);
Field(x => x.WeightLbs);
Field<StringGraphType>("pngimagePath", resolve: context => $"{context.Source.Name} {context.Source.BirthDate} {context.Source.BirthPlace}");
}
}
answered Nov 28 '18 at 7:33
Tao ZhouTao Zhou
6,92331332
6,92331332
Thanks much for your inputs :). It helped me a lot. I will implement it.
– santosh kumar patro
Nov 28 '18 at 7:50
add a comment |
Thanks much for your inputs :). It helped me a lot. I will implement it.
– santosh kumar patro
Nov 28 '18 at 7:50
Thanks much for your inputs :). It helped me a lot. I will implement it.
– santosh kumar patro
Nov 28 '18 at 7:50
Thanks much for your inputs :). It helped me a lot. I will implement it.
– santosh kumar patro
Nov 28 '18 at 7:50
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53506345%2fhow-to-generate-dynamic-path-value-for-a-graphql-query-response-using-graphql-ne%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What do you mean by generate image path? Does
api/tax/v1/countries
callGraphQL.NET
? Have you usedGraphQL.NET
or you want to migrate web api to it?– Tao Zhou
Nov 28 '18 at 2:14
I am in the process of migrating the existing REST APIs to GraphQL endpoint using GraphQL.NET. In the existing response as mentioned in my query there is "pngimagePath": "test.com/api/tax/v1/country/Country1/4/image/FlagPNG" and "svgimagePath": "test.com/api/tax/v1/country/Country1/405/image/FlagSVG". As part of the graphql response for this query I also need to expose these properties also. Can you please help me to know how to accomplish this implementation
– santosh kumar patro
Nov 28 '18 at 7:02