Skip to content

chore: example for setters argument for @rest directive #68

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

Merged
merged 8 commits into from
Feb 14, 2025

Conversation

asararatnakar
Copy link
Collaborator

@asararatnakar asararatnakar commented Jan 29, 2025

example to demonstrate setters argument for the directive @rest

Copy link
Contributor

@ddebrunner ddebrunner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Snippets are meant to be focused on a single concept, so I think here the concept of a transformation followed by a setter will just confuse.

I would instead have a simulated response and just use setters to pull the data from that response.

Signed-off-by: asararatnakar <[email protected]>
Signed-off-by: asararatnakar <[email protected]>
Copy link
Contributor

@ddebrunner ddebrunner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor changes would be good.

@@ -0,0 +1,41 @@
# This example demonstartes mapping a JSON response to the fields of the GraphQL.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo "demonstartes"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"of a GraphQL object"

@@ -0,0 +1,41 @@
# This example demonstartes mapping a JSON response to the fields of the GraphQL.

type Customer {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, can we have the GraphQL object have the natural names and the response have "weird" names

setters: [
{ field: "cId", path: "id" } # JSON response field 'id' is mapped to GraphQL 'cId'
{ field: "cName", path: "name" } # JSON response field 'name' is mapped to GraphQL 'cName'
{ field: "cAddress", path: "address" } # JSON response field 'address' mapped to GraphQL 'cAddress'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add one with a nested path, to show that is supported, e.g.

{ field: "address", path: "location.address" }

Copy link
Contributor

@ddebrunner ddebrunner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GTG

@ddebrunner ddebrunner merged commit 3ace8a1 into main Feb 14, 2025
1 check passed
@ddebrunner ddebrunner deleted the add_setters branch February 14, 2025 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants