Skip to content
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

Explore a "fluent" builder for GraphQL queries/mutations #1132

Open
nozzlegear opened this issue Jan 21, 2025 · 0 comments
Open

Explore a "fluent" builder for GraphQL queries/mutations #1132

nozzlegear opened this issue Jan 21, 2025 · 0 comments
Labels
enhancement experimental Deals with experimental features or changes that may not be published in ShopifySharp itself RFC Request for comments

Comments

@nozzlegear
Copy link
Owner

nozzlegear commented Jan 21, 2025

I'm very interested in adding a "fluent" query builder for GraphQL queries/mutations. Here's what I envision it looking like:

var builder = new GraphQueryBuilder();
var pageInfoFragment = new GraphQueryFragmentBuilder("pageInfoFragment", pageInfo =>
  pageInfo.StartCursor().EndCursor().HasNextPage().HasPreviousPage());

var query = builder.Query(query =>
  query.Products(p =>
    p.Arguments.First(10);
    p.PageInfo(pageInfo => pageInfo.Fragment(pageInfoFragment));
    p.Nodes(node =>
      node.Id();
      node.Title();
      node.VariantsCount(v => v.Count());
   )
  .Shop(s =>
    s.Id();
    s.Title();
    s.Plan(p => p.DisplayName());
  )
).Build();

var request = new 

One of the things I like about this is the potential for reusing parts of the code (such as the pageInfo fragment). This is just pseudo-code so there are a lot of actual implementation questions that are unanswered here, but I'd love to hear feedback about this before I start implementing it (and don't forget to check #1137 and #1072 as well).

@nozzlegear nozzlegear converted this from a draft issue Jan 21, 2025
@nozzlegear nozzlegear added enhancement experimental Deals with experimental features or changes that may not be published in ShopifySharp itself RFC Request for comments labels Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement experimental Deals with experimental features or changes that may not be published in ShopifySharp itself RFC Request for comments
Development

No branches or pull requests

1 participant