Comments (7)
I'll try to add this some time this weekend.
from pothos.
published a pre-release with the above API. Version info is in the PR description. Docs are in the first file in the chage-set if you want to try it out
from pothos.
Are defining the field on both the interface and the UserNode? I think of you omit the field on UserNode it would work, but I suspect you want a different resolver. I think for now you would need to manually define your connection object and implement the field like any other field. In general there isn't a way to re-use the connection types for multiple fields which is effectively what you need. I'll have to think about a solution for this that isn't just manually implementing everything.
from pothos.
Yes I'm defining the field on 3 things the Feed
, the Profile
and the Page
.
My problem is effectively that I have a Feed
and a Profile
both of which have posts.
On the client I have a PostList component that uses a fragment to get the posts and I wanted to be able to reuse it between the Feed and Profile pages.
But to solve my problem for now what do you mean by manually defining my connection object?
from pothos.
If I can't find a nice solution to this I might just create two separate components for my post lists which might be the more correct thing to do
from pothos.
I am thinking about adding an API like:
const SharedConnection = builder.connectionObject(NumberThing);
builder.queryField('sharedConnection', (t) =>
t.field({
type: SharedConnection,
nullable: true,
args: {
...t.arg.connectionArgs(),
},
resolve: (root, args) =>
resolveOffsetConnection({ args }, ({ limit, offset }) => {
const items = [];
for (let i = offset; i < Math.min(offset + limit, 200); i += 1) {
items.push(new NumberThing(i));
}
return items;
}),
}),
);
Basically this would allow you to define a connection object type that is re-usable in multiple field definitions, adding an API to create connection args. This would let you define a PostsConnection
object type, and then use that to define a field on your Page interface, as well as your Profile and Feed objects. The issue is that currently there is no way to use the same Connection type on multiple fields (a requirement for fields defined on interfaces)
from pothos.
That would be great. This is pretty much the solution I was hoping for 💯
from pothos.
Related Issues (20)
- Subgraph Plugin is dropping deprecation hints in InputTypes HOT 1
- Infer type from object ref HOT 3
- Prisma preview feature `extendedWhereUnique` is not type-compatible with indirect relations as connections using `plugin-prisma` HOT 2
- GraphQL Shield Not Authorized on Null Field HOT 1
- Cannot return null from nullable prisma connection resolver HOT 3
- prismaUtils Static generator prismaWhere without AND OR NOT HOT 1
- ValidationPlugin: Zod types seem to mismatch what Pothos expect HOT 4
- PothosError: builder.prismaNode requires @pothos/plugin-relay to be installed HOT 1
- Support offset pagination for prisma connection HOT 4
- [Feature request] Need to find a plugin similar to `nexus-result-field` for Pothos. HOT 1
- PothosSchemaError: Ref Query has not been implemented HOT 3
- [plugin-relay] mutations throwing `PothosSchemaError: Ref Mutation has not been implemented` HOT 1
- Codegen generated type not match resolver arg type HOT 5
- Unknown Type Error with Subgraph and Federation Plugins HOT 3
- Type issue: required/optional fields HOT 2
- [Question] How to describe fields or resolvers by dividing it HOT 1
- federation-plugin: toSubGraphSchema is not a function HOT 7
- [Errors plugin] returns `Ref ${String(ref)} has not been implemented` when used togeher with user defined scalars
- [@pothos/plugin-prisma] Cannot read properties of undefined with Prisma 4.14.0 HOT 3
- Prisma-utils inputs can't set null values HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pothos.