How to think about SSG when API changes are part of the same PR #11285
Replies: 3 comments 5 replies
-
Check this answer: Basically don't do a literal |
Beta Was this translation helpful? Give feedback.
-
@timneutkens the answer above was satisfactory for quite some time, but I'm bumping into some confusing behaviors when running a single GraphQL endpoint and doing new deployments. Suppose I am writing a new query with a new resolver. When I deploy this, I have to supply a It seems like I want something like:
Does this issue make sense to you, or am I still missing something? |
Beta Was this translation helpful? Give feedback.
-
@brianlovin if your GraphQL server is based on graphql-js (eg: Apollo), you may be able to use it directly without the need for HTTP request. import { graphql } from 'graphql';
import schema from '../schema'; // GraphQLSchema, you can build using makeExecutableSchema for example
// In getStaticProps/getServerSideProps
let body = await graphql({
schema,
source: 'query { ... }',
contextValue: ...,
variableValues: ...,
}); This can be part of your server-side network layer implementation for Relay/Apollo/etc. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm currently rebuilding the api for my personal site. In doing so, I did the following (generally):
pages/api/graphql.ts
routepages/index.tsx
pagegetStaticProps
to fetch from/api/graphql
I'm confused about how to think about the right way to deploy this. It seems that the
getStaticProps
would need to read data from an API route that doesn't exist yet, or is being simultaneously built. This caused me a lot of frustration as I basically had to comment out a ton of code, deploy the API Routes, then rebuild my client side data fetching.Any suggestions on this would be great!
Beta Was this translation helpful? Give feedback.
All reactions