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

Export createRouter and createSofa methods #1459

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

Conversation

ernestognw
Copy link

Preamble

Currently, SOFA evaluates whether a type is a model or not by looking for both a single endpoint with a non-optional id and a list endpoint that returns a raw list of the type.

However, some more mature schemas will reasonably change the way objects are accessed to include pagination or even intermediate nodes ala Github. For example:

type Chat {
  id: ID
  text: String
}

type ChatList {
  results: [Chat]
  cursor: String
}

type Query {
  chat(id: ID): Chat
  chats: ChatList
  me: Chat
  recentChats: ChatList
}

While it'd ideal for SOFA to understand this kind of special syntax for identifying models, it turns out to be easier for bigger codebases to manually pass the models argument into createRouter. This is not currently possible with the current exports defined by the library.

Description

This PR allows for anyone to replace useSofa with the use of createRouter and createSofa, so that custom configuration can be hooked in.

Copy link

changeset-bot bot commented May 12, 2024

🦋 Changeset detected

Latest commit: c34721f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
sofa-api Patch

Not sure what this means? Click here to learn what changesets are.

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

@ernestognw ernestognw changed the title Chore: Export createRouter and createSofa methods Export createRouter and createSofa methods May 12, 2024
@Urigo
Copy link
Owner

Urigo commented May 15, 2024

Thank you for your PR!
We'll review soon
Would you be up to have a chat with us and share your use case for SOFA and how and with which tools you are currently using it?

@ernestognw
Copy link
Author

Thank you for your PR! We'll review soon Would you be up to have a chat with us and share your use case for SOFA and how and with which tools you are currently using it?

Thanks! Yeah sure, I'm working on a side project after a couple of years of not using GraphQL and I'm very amazed with all of the tooling you guys have developed.

Feel free to contact me at [email protected]

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