tinacms / tina-graphql-gateway

Makes it easier to build TinaCMS websites with a GraphQL Layer.
https://tina.io/cloud
Apache License 2.0
6 stars 2 forks source link

Easier setup #338

Closed jeffsee55 closed 3 years ago

jeffsee55 commented 3 years ago

Closes https://github.com/tinacms/tina-graphql-gateway/issues/337

This adds a /light route to the tina-graphql-gateway which only bundles the EditProvider state. As I was testing things out I just cut out a bunch of stuff to see how it'd feel. I think we should talk about:

Just less touch points for tina init. And then obviously continue to document how to compose this stuff yourself. But if we can do this, the only touch point for Tina in your nextjs app is at the _app.js file:

import dynamic from 'next/dynamic'
import { TinaEditProvider } from 'tina-graphql-gateway/dist/light'
const Tina = dynamic(() => import('tina-graphql-gateway'), { ssr: false })

// Our app is wrapped with edit provider
function App({ Component, pageProps }) {
  return (
    <TinaEditProvider
      editMode={
        <Tina
          config={{
            branch: 'main',
            clientId: process.env.NEXT_PUBLIC_TINA_CLIENT_ID,
            organization: process.env.NEXT_PUBLIC_ORGANIZATION_NAME,
            isLocalClient: Boolean(
              Number(process.env.NEXT_PUBLIC_USE_LOCAL_CLIENT)
            )
          }}
          {...pageProps}
        >
          {(livePageProps) => <Component {...livePageProps} />}
        </Tina>
      }
    >
      <Component {...pageProps} />
    </TinaEditProvider>
  )
}

export default App
changeset-bot[bot] commented 3 years ago

⚠️ No Changeset found

Latest commit: 8ca2118eff52b8671854aa3843dcb199127bec1a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes changesets to release 10 packages | Name | Type | | ------------------------------- | ----- | | tina-graphql | Minor | | tina-graphql-gateway | Minor | | tina-graphql-gateway-cli | Minor | | tina-cloud-starter-experimental | Patch | | tina-graphql-helpers | Patch | | demo | Patch | | test | Patch | | next-tinacms-cloudinary | Major | | tina-cloud-starter | Patch | | tina-tailwind-sidebar-demo | Patch |

Click here to learn what changesets are, and how to add one.

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