Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"GraphQL query for this page" button #82

Open
berekuk opened this issue May 12, 2022 · 0 comments
Open

"GraphQL query for this page" button #82

berekuk opened this issue May 12, 2022 · 0 comments

Comments

@berekuk
Copy link
Collaborator

berekuk commented May 12, 2022

It'd be cool to have a link to yoga playground on every metaforecast page which would expose a query with data for this page.

Shouldn't be hard if all our pages follow the pattern of "query for data in getServerSideProps" — we'll just need some kind of extension for NextPage object with graphql query as a property on it.

Draft:

export const MyPage: GraphQLPage = () => {
  return (
    <Layout query={MyPage.query}>
      ...
    </Layout>
  );
};

MyPage.query = MyPageDocument;

MyPage.variables = (context) => ({
  id: context.query.id,
});

export const getServerSideProps = getGraphQLServerSideProps(MyPage);

I'm not sure if this example would be flexible enough, and it'd be better to build more various graphql-based pages before doing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant