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

Wrong import of type Prisma in Flow Example #310

Closed
geroj opened this issue Nov 30, 2018 · 7 comments
Closed

Wrong import of type Prisma in Flow Example #310

geroj opened this issue Nov 30, 2018 · 7 comments
Assignees
Labels
kind/bug A reported bug.

Comments

@geroj
Copy link

geroj commented Nov 30, 2018

I've found error while trying out your Flow graphql example

There is not correct import of type Prisma in file types.js
https://github.com/prisma/prisma-examples/blob/master/flow/graphql/src/types.js

There is work around which works for me

/**
 * @flow
 */

import { Prisma } from './generated/prisma-client'

export type ExtractReturn<Fn> = $Call<<T>((...Iterable<any>) => T) => T, Fn>;

export interface Context {
  prisma: ExtractReturn<typeof Prisma>;
}

based on facebook/flow#4002 (comment)

Another option would be exposing PrismaInterface from

@nikolasburk
Copy link
Member

nikolasburk commented Nov 30, 2018

Thanks for opening this issue. What exactly is the error you're seeing? I can't reproduce it at the moment, everything works fine for me when using the instructions from the README.

Can you please post the error message you're seeing and explain when exactly the error occurs?

@geroj
Copy link
Author

geroj commented Nov 30, 2018

First thing, there is no @ sign in front of flow in line 2 https://github.com/prisma/prisma-examples/blob/master/flow/graphql/src/types.js

After adding it. It can't recognize path ../../generated/prisma-client

After changing path there is following flow error:

Cannot import the value `Prisma` as a type. `import type` only works on type exports. Like type aliases, interfaces, and classes. If you intended to import the type of a value use `import typeof` instead.

@nikolasburk
Copy link
Member

Thanks, do you want to submit a PR to fix this? Otherwise I can look into it later today :)

@geroj
Copy link
Author

geroj commented Nov 30, 2018

I think that it will be better when you will have look into this. My solution is just workaround for issue that generated types don't export PrismaInterface. Thank you :)

@nikolasburk nikolasburk added the kind/bug A reported bug. label Nov 30, 2018
@nikolasburk nikolasburk self-assigned this Nov 30, 2018
@nikolasburk
Copy link
Member

nikolasburk commented Nov 30, 2018

Instead of using your workaround, I could fix the issue with using import typeof instead of import type. Do you see any issues with that solution @geroj?

Edit: Hmm, I realize this probably not what we want - but indeed we probably want to export the PrismaInterface from the generated client code.

@divyenduz
Copy link
Contributor

This is fixed in beta version 1.25.0-beta.4. Please give it a go via npm install -g prisma@beta and let me know if that works for you. Thanks.

@stale
Copy link

stale bot commented Feb 24, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 10 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status/stale label Feb 24, 2019
@stale stale bot closed this as completed Mar 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A reported bug.
Projects
None yet
Development

No branches or pull requests

3 participants