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

Enhancement/graphql custom resolvers and typedefs #509

Merged

Conversation

thescientist13
Copy link
Member

@thescientist13 thescientist13 commented Apr 4, 2021

Related Issue

resolves #508

Summary of Changes

  1. Added the ability for users to provide a schema (defs / resolvers) in a directory called {workspace}/data/schema/

Screen Shot 2021-04-04 at 3 54 18 PM

Screen Shot 2021-04-04 at 4 23 33 PM

Found a bug in #573 that will prevent the formal demo here from working with build until it is merged since I am using a second inline <script> but the this PR does work. You should be able to validate by merging that branch into here.

TODO

  1. Flesh out example in www/ to actually pull images from a directory in the resolver (based on a variable)
    • multiple galleries (query should take a variable) sourced from frontmatter
    • demonstrate a gallery somewhere
  2. Allow configuration for data/schema locations - captured in Shared Workspaces and Contexts (Theme Packs) #570
  3. How can plugins define or provide this to plugin-graphql (similar naming convention as default?) - Shared Workspaces and Contexts (Theme Packs) #570
  4. Maybe for [RFC] External Data (Graph) Sources #21 , it could be more about how to get things into the graph specifically? - updated
  5. support an assets graph - create an assets schema (assets.json) with queries and resolvers for assets as data #571
  6. Test cases
  7. Documentation
  8. Revert example code

@thescientist13 thescientist13 added enhancement Improve something existing (e.g. no docs, new APIs, etc) question Further information is requested documentation Greenwood specific docs Content as Data labels Apr 4, 2021
@thescientist13 thescientist13 self-assigned this Apr 4, 2021
let customDataDefs = '';
module.exports = (compilation) => {
const { graph } = compilation;
const uniqueCustomDataDefKeys = {};
Copy link
Member Author

@thescientist13 thescientist13 Apr 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming / organization could maybe some have thought here, just so it's clearer what everything is and where it is coming from. (from greenwood, from user, from user content, etc)

module.exports = (compilation) => {
const { graph } = compilation;
const uniqueCustomDataDefKeys = {};
const customSchemasPath = `${compilation.context.userWorkspace}/data/schema`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is great for unique queries for each individual user. If you want to extend it to have plugins include schema, we would need to do an additional directory walk of any plugins containing a graphql flag of somekind.

Copy link
Member

@hutchgrant hutchgrant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good for individual users wanting to BYOQ(bring your own query) because now they can write custom resolvers and utilize the graph in many different ways. The gallery, as an example, is fine. But would like to confine the gallery typedefs + resolver + query + wrapper component to its own plugin package eventually.

@thescientist13 thescientist13 added CLI todos and removed question Further information is requested labels Apr 17, 2021
@thescientist13 thescientist13 force-pushed the enhancement/graphql-custom-resolvers-and-typedefs branch from f51f001 to 7de013b Compare April 24, 2021 16:23
@thescientist13 thescientist13 marked this pull request as ready for review April 24, 2021 22:39
@thescientist13 thescientist13 removed their assignment Apr 24, 2021
@thescientist13 thescientist13 self-assigned this Apr 24, 2021
@thescientist13 thescientist13 removed their assignment May 7, 2021
@thescientist13 thescientist13 merged commit 4c521d9 into master May 8, 2021
@thescientist13 thescientist13 deleted the enhancement/graphql-custom-resolvers-and-typedefs branch May 8, 2021 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI Content as Data documentation Greenwood specific docs enhancement Improve something existing (e.g. no docs, new APIs, etc)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support ad-hoc / custom GraphQL resolvers and definitions (schemas)
2 participants