Comments (2)
Hello crirus! For example, the client has this Query:
Products (id:20) {
Price,
Name,
BrandName
}
The Query will return JSON with this Fields: Price, Name and Brand Name. But if client wants only name, the Query must be:
Products (id:20) {
Name
}
The Customer/Client will choose what to return by the Query. The Application, in the resolver, must populate with data from Database/File, etc
from graphqlite.
Hey @crirus!
@jmurrayrs answer is correct. The whole purpose of GraphQL is to let you fetch exactly the fields you need. If this is not obvious to you, maybe you can take a look at the main GraphQL tutorial.
Now, I feel that you already know that and that your question is rather: "is there a way to get in advance the list of fields that I will have to resolve"?
And I also guess you are asking because your backend is a database and you would like to fetch only the columns that will be needed instead of fetching all the columns? Am I correct?
If this is what you are trying to do, we added in GraphQLite 4 a new way to access the GraphQL request.
GraphQLite is built on top of the webonyx/graphql-php. This library comes with a "ResolveInfo" object that contains information related to the requested fields.
You can now type-hint on ResolveInfo
in any resolver.
See documentation here:
https://graphqlite.thecodingmachine.io/docs/next/query-plan
Please note this is only available in GraphQLite 4. It is not yet tagged stable but will be in less than a month, and I don't expect any more breaking changes, so you can start using GraphQLite 4 right now.
from graphqlite.
Related Issues (20)
- Support readonly input classes with constructors HOT 20
- Implement Persisted Queries mechanism to easily allow server-side Caching HOT 14
- Field nullable union type is throwing an error HOT 1
- Performance problem even for small query on big schema. HOT 33
- Improve #[InjectUser] to throw authentication errors HOT 1
- First party support for `void` return type HOT 3
- Please, publish a new version HOT 1
- Extension packages are unmaintained or don't support latest features HOT 11
- doctrine/annotations should be upgraded to v2 HOT 2
- Mutability concerns HOT 5
- Cleanup and deprecate confusing annotations HOT 2
- New patch version HOT 3
- Mapping multiple php object representations for a single resource to one graphql ObjectType HOT 4
- Automatic query complexity HOT 1
- Empty request body parsing error for automatic persisted queries HOT 14
- prefetchMethod does not work HOT 12
- Arguments description in schema HOT 3
- Undocumented Error or posible dead code HOT 3
- ExtendType and Type with class argument don't work
- Defining fields in type by trait from different namespace ends with error for relative type declarations HOT 2
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 graphqlite.