Skip to content

useLazyLoadedSchema do not support promise #1381

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

Closed
Moumouls opened this issue Apr 29, 2022 · 5 comments
Closed

useLazyLoadedSchema do not support promise #1381

Moumouls opened this issue Apr 29, 2022 · 5 comments

Comments

@Moumouls
Copy link

Is your feature request related to a problem? Please describe.

const server = createServer({
      plugins: [useLazyLoadedSchema(() => this.parseGraphQLSchema.load())]
    })

Lazy loading do not support promises.

Describe the solution you'd like
Support promises for lazyLoaded schema

Describe alternatives you've considered
No alternative found

Additional context

@Moumouls
Copy link
Author

Look strange since because in the docs i see.

async function getSchema({ req }): GraphQLSchema {
  if (req.isAdmin) {
    return adminSchema;
  }

  return userSchema;
}

@Moumouls
Copy link
Author

I see on the master branch

export const useLazyLoadedSchema = (schemaLoader: (context: Maybe<DefaultContext>) => GraphQLSchema): Plugin => {
  return {
    onEnveloped({ setSchema, context }) {
      setSchema(schemaLoader(context));
    },
  };
};

export const useAsyncSchema = (schemaPromise: Promise<GraphQLSchema>): Plugin => {
  return {
    onPluginInit({ setSchema }) {
      schemaPromise.then(schemaObj => {
        setSchema(schemaObj);
      });
    },
  };
};

setSchema seems to expect a GraphQLSchema not a Promise

@Moumouls
Copy link
Author

@dotansimha I'm right?

@Moumouls
Copy link
Author

after some investigation, it seems the source of the issue.

Error: Expected {} to be a GraphQL schema.

For parse-server we need promise support for useLazyLoadedSchema.

@Urigo

@n1ru4l
Copy link
Collaborator

n1ru4l commented Aug 16, 2022

I think this is kind of resolved in the next major release we will remove useLazyLoadedSchema

@n1ru4l n1ru4l closed this as completed Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants