这是indexloc提供的服务,不要输入任何密码
Skip to content

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

@nozzlegear

Description

@nozzlegear

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCRequest for commentsenhancementexperimentalDeals with experimental features or changes that may not be published in ShopifySharp itself

    Projects

    Status

    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions