Skip to content

Conversation

@XiNiHa
Copy link
Owner

@XiNiHa XiNiHa commented Jul 24, 2025

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Jul 24, 2025

⚠️ No Changeset found

Latest commit: d84d9a8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @XiNiHa, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the solid-relay documentation by introducing a comprehensive set of guides. These new documents aim to provide a much friendlier and more detailed onboarding experience for users, covering fundamental concepts from initial setup to advanced data fetching patterns like fragments, mutations, and real-time subscriptions.

Highlights

  • Getting Started Guide: Replaced the previous placeholder with a comprehensive "Getting Started" guide, covering installation, Relay Environment setup, and basic query usage.
  • Fragments Documentation: Added a new guide detailing the usage of createFragment, createRefetchableFragment, and createPaginationFragment for managing reusable query logic.
  • Queries Documentation: Introduced a new guide explaining createLazyLoadQuery for simple data fetching and createPreloadedQuery for performance optimization through preloading.
  • Mutations Documentation: Added a dedicated guide for createMutation, demonstrating how to perform data modifications on the server.
  • Subscriptions Documentation: Included a new guide on setting up the network for real-time updates and using createSubscription to listen for live data changes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jul 24, 2025

Open in StackBlitz

npm i https://pkg.pr.new/XiNiHa/solid-relay@38

commit: d84d9a8

@codecov
Copy link

codecov bot commented Jul 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 27.77%. Comparing base (1fdff00) to head (d84d9a8).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #38   +/-   ##
=======================================
  Coverage   27.77%   27.77%           
=======================================
  Files          21       21           
  Lines        1422     1422           
  Branches       73       73           
=======================================
  Hits          395      395           
  Misses       1027     1027           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cloudflare-workers-and-pages
Copy link

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
solid-relay d84d9a8 Commit Preview URL

Branch Preview URL
Jul 24 2025, 01:28 PM

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This PR introduces valuable documentation for solid-relay. I've identified several inaccuracies in the examples related to createRefetchableFragment, createPaginationFragment, createPreloadedQuery, and createSubscription. The provided feedback aims to correct these examples for a better user experience.

Comment on lines +41 to +92
## `createPreloadedQuery`

`createPreloadedQuery` allows you to start loading data before the component is rendered. This can improve performance by reducing the time it takes to display the data.

To use `createPreloadedQuery`, you first need to create a query loader.

```typescript
// loaders.ts
import { createQueryLoader } from "solid-relay";
import { graphql } from "relay-runtime";
import type { UserQuery } from "./__generated__/UserQuery.graphql";

export const userQuery = createQueryLoader<UserQuery>(
graphql`
query UserQuery($id: ID!) {
user(id: $id) {
name
}
}
`
);
```

Then you can use the `load` method of the query loader to start loading the data.

```typescript
// index.tsx
import { userQuery } from "./loaders";

userQuery.load({ id: "1" });
```

Finally, you can use `createPreloadedQuery` to get the data in your component.

```tsx
// User.tsx
import { Show } from "solid-js";
import { createPreloadedQuery } from "solid-relay";
import { userQuery } from "./loaders";

const User = () => {
const query = createPreloadedQuery(userQuery);

return (
<Show when={query()}>
{(data) => <p>{data().user.name}</p>}
</Show>
);
};
```

This will render the component with the preloaded data. If the data is not yet available, the component will suspend.

Choose a reason for hiding this comment

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

critical

The createPreloadedQuery documentation is inaccurate and doesn't reflect the correct API usage of createQueryLoader and createPreloadedQuery.

  1. createQueryLoader returns a tuple [queryReference, loadQuery, disposeQuery], not an object with a .load method.
  2. createPreloadedQuery requires two arguments: the GraphQL query node and the preloaded query reference. The example only passes one.

Corrected documentation:

## `createPreloadedQuery`

`createPreloadedQuery` allows loading data before component rendering, improving performance.

First, create a query loader:

```typescript
// loaders.ts
import { createQueryLoader } from "solid-relay";
import { graphql } from "relay-runtime";
import type { UserQuery } from "./__generated__/UserQuery.graphql";

export const UserQueryNode = graphql`
  query UserQuery($id: ID!) {
    user(id: $id) {
      name
    }
  }
`;

export const [userQueryRef, loadUserQuery] =
  createQueryLoader<UserQuery>(UserQueryNode);

Use loadUserQuery to load data (e.g., in a router):

// index.tsx
import { loadUserQuery } from "./loaders";

loadUserQuery({ id: "1" });

Then, use createPreloadedQuery in your component, passing both the query node and the query reference:

// User.tsx
import { Show } from "solid-js";
import { createPreloadedQuery } from "solid-relay";
import { UserQueryNode, userQueryRef } from "./loaders";

const User = () => {
  const query = createPreloadedQuery(UserQueryNode, userQueryRef);

  return (
    <Show when={query()}>
      {(data) => <p>{data().user.name}</p>}
    </Show>
  );
};

Comment on lines +66 to +82
const CommentNotification = () => {
createSubscription<CommentNotificationSubscription>(
graphql`
subscription CommentNotificationSubscription($postId: ID!) {
commentAdded(postId: $postId) {
id
body
}
}
`,
{
variables: {
postId: "1",
},
}
);

Choose a reason for hiding this comment

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

critical

The createSubscription function expects a single configuration object. The current example passes the GraphQL subscription and variables as separate arguments, which is incorrect.

createSubscription<CommentNotificationSubscription>({
  subscription: graphql`
    subscription CommentNotificationSubscription($postId: ID!) {
      commentAdded(postId: $postId) {
        id
        body
      }
    }
  `,
  variables: {
    postId: "1",
  },
});

Comment on lines +51 to +67
graphql`
fragment Post_post on Post @refetchable(queryName: "PostRefetchQuery") {
title
body
}
`,
() => props.post
);

return (
<div>
<h2>{post().title}</h2>
<p>{post().body}</p>
<button onClick={() => refetch({ id: props.post.id })}>Refetch</button>
</div>
);
};

Choose a reason for hiding this comment

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

medium

The example for createRefetchableFragment is missing the id field in the Post_post fragment. This field is necessary for Relay to identify the entity to refetch. Additionally, props.post is an opaque fragment reference and doesn't directly expose properties like id. Including id in the fragment allows solid-relay to automatically handle refetching with refetch({}).

fragment Post_post on Post @refetchable(queryName: "PostRefetchQuery") {
  id
  title
  body
}
    `,
    () => props.post
  );

  return (
    <div>
      <h2>{post().title}</h2>
      <p>{post().body}</p>
      <button onClick={() => refetch({})}>Refetch</button>
    </div>

Comment on lines +83 to +95
graphql`
fragment Comments_post on Post @refetchable(queryName: "CommentsPaginationQuery") {
comments(first: 10) @connection(key: "Comments_comments") {
edges {
node {
id
body
}
}
}
}
`,
() => props.post

Choose a reason for hiding this comment

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

medium

The Comments_post fragment should include the id field on the Post type. This id is crucial for solid-relay to manage pagination and refetching correctly, as it's used to identify the connection.

fragment Comments_post on Post @refetchable(queryName: "CommentsPaginationQuery") {
  id
  comments(first: 10) @connection(key: "Comments_comments") {
    edges {
      node {
        id
        body
      }
    }
  }
}

@XiNiHa XiNiHa closed this Jul 25, 2025
@XiNiHa XiNiHa deleted the add-docs branch August 12, 2025 16:22
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