Comments (4)
Hey, thanks for reaching out!
The toolkit doesn't really care how you execute GraphQL queries. It just expects you to provide a function:
execute({ query, operationName, variables })
that returns a standard GraphQL response (actually a Promise for this response):
{
data: {
// response data
},
errors: []
}
You can use persisted queries or just send a full query. That is totally up to you. We do provide a default implementation of such execute
function but you can easily swap it with your own.
If you want you can use Apollo links inside this function:
const { toPromise, execute as apolloExecute } = require('apollo-link');
const myApolloLink = createPersistedQueryLink({useGETForHashedQueries: true})
.concat(createHttpLink({ uri: `https://${process.env.DATA_SOURCE_URL}/graphql`, fetch: fetch }))
async function execute({ query, operationName, variables }) {
return toPromise(apolloExecute(myApolloLink , { query, operationName, variables }))
}
But as for me, apollo links introduce unnecessary overhead. Still, you can use them if you want.
from gatsby-graphql-toolkit.
Thanks @vladar! I see how I would set a custom execute
when writing a source plugin using the toolkit. Do you expect that a site using your new gatsby-source-drupal-graphql
would eventually be able to also override just the execute
function from configuration?
from gatsby-graphql-toolkit.
I think yes. It makes sense to expose execute
as an option. But it depends on how gatsby-source-drupal-graphql
plugin will be implemented. So it's up to the plugin author to decide (I will just prepare an initial prototype for this).
from gatsby-graphql-toolkit.
sounds good! thanks @vladar.
from gatsby-graphql-toolkit.
Related Issues (20)
- feat: display error on 4xx/5xx http error codes HOT 4
- Stale data invalidation with delta syncing
- Add ability to map custom scalar types HOT 2
- Feat: a way to avoid certain references HOT 4
- Duplicate nodes overwrite unique nodes, resulting in missing Gatsby GraphQL nodes. HOT 1
- Invalid object Node Ids create an unclear error message HOT 1
- Sourcing non-list data HOT 1
- Nullable lists are transformed into non-nullable lists HOT 8
- gatsby 4 - cannot call `createTypes` in the `sourceNodes` API HOT 1
- Toolkit throws TypeError if query returns a non-iterable object
- GraphQL 16 compatibility HOT 2
- Cannot query field HOT 1
- success fetching Nodes, but no Gatsby nodes created. HOT 1
- Accept a function as `gatsbyTypePrefix` .
- Complains about null for non-null type HOT 1
- Fails to execute LIST_ query with NoPagination
- wagtail grapple support
- Import interfaces from source schema
- Cannot query field on type "Query" HOT 1
- LIST does not fetch all data HOT 5
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 gatsby-graphql-toolkit.