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

chore: increase documentation across the codebase #503

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

gnottobfly
Copy link

@gnottobfly gnottobfly commented May 3, 2023

This PR aims to provide meaningful documentation on this library. This comes in three forms:

  1. a usage guide in the README.md
  2. comprehensive JSDoc comments on public interfaces
  3. a full example application that shows the usage of the library in a real application

README.md Outdated Show resolved Hide resolved
@jquense
Copy link
Member

jquense commented May 3, 2023

🙌

Copy link

@shatch-bfly shatch-bfly left a comment

Choose a reason for hiding this comment

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

thanks Gino! I struggle every time I have to traverse code that uses this, very helpful for me!


## What is a Node?

A `Node` is a refetchable GraphQL resource. All `Node`s must have a _globally unique ID_ and be fetchable via this ID. Relay will refetch these resources in the following way:

Choose a reason for hiding this comment

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

suggestion: maybe reference the gql interface, perhaps even update the code snippet below such that Foo implements Node? The Node interface is the fundamental part, right? it's the smart impl that's the magic?

* first.
*
* Even if multiple fields use the `createResolve` helper, there will only
* be one network request as the requests will be batched via a DataLoader.

Choose a reason for hiding this comment

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

question: there needs to be batch-compliant endpoints on the backing api to support, right? does the example api need to call that out?

Copy link
Author

Choose a reason for hiding this comment

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

I never answered this but that is orthogonal to the createResolve helper. What you are talking about is the DataLoader that is by default used in the HttpApi class.

That is a good point though and dataloading should be the next portion.

'/graphql',
graphqlHTTP({
schema: new GraphQLSchema({ query: Query }),
graphiql: true,

Choose a reason for hiding this comment

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

question: I havent used this in a while! adding the playground (if you need it) is pretty simple (middleware)

Copy link
Author

Choose a reason for hiding this comment

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

I don't quite understand what this does? Currently the GraphiQL Playground is being hosted and accessible via localhost when running yarn start.


The [NodeType](./src/types/NodeType.ts#) class does two things:
1. it defines the `Node` type required by Relay
1. it implements a solution to asynchronously resolve the Node by fetching it from a backing REST API

Choose a reason for hiding this comment

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

suggestion: just want to make sure I understanding the semantics clearly, this is most likely just me making noise...

  1. does it define the Node or does it provide the concrete implementation for a Node in the relay sense?
  2. the solution is just an implementation of the relay gql interface that's got some smarts, right? provides implementation for node, nodes by asynchronously fetching...?

}
```

## The Node Class

Choose a reason for hiding this comment

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

question: this is kind of ambiguous to me, should I be reading this something like, "The NodeType, a sensible Node Implementation"?

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.

5 participants