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

TypeError: buildASTSchema.getDescription is not a function #111

Closed
silkyland opened this issue Dec 16, 2017 · 30 comments
Closed

TypeError: buildASTSchema.getDescription is not a function #111

silkyland opened this issue Dec 16, 2017 · 30 comments
Labels
🎙️question Further information is requested

Comments

@silkyland
Copy link

I got this error

TypeError: buildASTSchema.getDescription is not a function .

Any help?

@bermanboris
Copy link

You can downgrade version of "graphql" dependency. Version ^0.11.7 is working fine for me!

@RichardLitt RichardLitt added the 🎙️question Further information is requested label Dec 17, 2017
@email2vimalraj
Copy link

Can this be fixed asap?
I'll also look into it and raise a PR if possible.

@RichardLitt
Copy link
Contributor

@email2vimalraj A PR would be great. For now, the above downgrade should work while we allocate time to process this.

@RodMachado
Copy link
Contributor

This could be related graphql/graphql-js#1165.
I'll verify if upgrading graphql will fix the problem.

@RodMachado
Copy link
Contributor

Hey @silkyland and @email2vimalraj
Apparently getDescription function from buildASTSchema was no longer being exported since version 0.12.0. The issue is fixed with this PR graphql/graphql-js@8173c24 but it is not available yet. It will probably be published in version 0.12.4 (I thought this was included in version 0.12.3, but it was not).

The solution for now is to use graphql version 0.11.7.

@email2vimalraj
Copy link

email2vimalraj commented Dec 26, 2017 via email

@Rajeshr34
Copy link

Works on latest GraphQL
Fix: yarn add graphql@git://github.com/graphql/graphql-js.git#npm

@j
Copy link

j commented Jan 23, 2018

No activity on this repo for a while. Wish it'd work out of the box with graphql-yoga

@RichardLitt
Copy link
Contributor

RichardLitt commented Jan 23, 2018

@j We're here :). Is it not working with graphql-yoga because of this issue? I'd be happy to escalate it.

@beebase
Copy link

beebase commented Jan 23, 2018

I'm having same error "TypeError: buildASTSchema.getDescription is not a function ."
with these versions

"graphql": "^0.12.3",
"graphql-yoga": "1.2.0",
"merge-graphql-schemas": "^1.4.0",

downgrading graphql to 0.11.7 seems to work but I have another question

schema.grapql imports a Type from another graphql file
image

...which results in this error. I suppose the import is not resolved by merge-graphql-schemas?
Is there another way to achieve this?
image

@RichardLitt
Copy link
Contributor

@RodMachado Can you offer an update on this one?

@cfnelson
Copy link
Contributor

@RichardLitt This isn't something we cam fix its due to graphql.js. See above explanation and answer by Rodrigo. @j @beebase The solution for now is to use graphql version 0.11.7. or switch to using the github branch instead of the npm pkg -> Fix: yarn add graphql@git://github.com/graphql/graphql-js.git#npm

Once graphql: 0.12.4 is released then this issue will resolve itself by upgrading to that version.

@RichardLitt
Copy link
Contributor

Thanks for clarifying, @cfnelson. I appreciate it - not sure how I missed that. 👍

@cfnelson
Copy link
Contributor

@beebase Sorry, I missed the 2nd part of your question. Yes we don't resolve imports inside a .graphql file. However merge-graphql-schemas should generate a single graphql types and one for your resolvers. Which you would then use to create your schema.

If your still having problems open up a new issue for the graphql-yogo issue you have. If you provide an example of how you are using merge-graphql-schemas we might be able to help.

@liuuu
Copy link

liuuu commented Jan 24, 2018

Hi. when I changed to github branch by
yarn add graphql@git://github.com/graphql/graphql-js.git#npm

popup: warning " > merge-graphql-schemas@1.4.0" has incorrect peer dependency "graphql@^0.11.7".

npm start
node_modules/graphql/utilities/buildASTSchema.js:188 throw new Error('Specified ' + operation + ' type "' + typeName + '" not found in document.'); ^
So, what's the problem?

@beebase
Copy link

beebase commented Jan 24, 2018

@cfnelson Thanks, I'll try to explain my problem.
I'm using prisma API, which generates a database API based on types you define in a database model.
so "type User {}" generates createUser, deleteUser, filterUser etc.. in prisma.graphql.
img2694
The schema.graphql is manually written and acts as a public layer in front of the prisma.graphql. (prisma is hidden to clients)
So when I define a public query "feed" (list of posts) I need to import the generated type Post from prisma.
img2696
Because # import doesn't work with merge-graphql-schemas, I thought lets just move prisma.graphql into the same directory as schema.graphql so everything gets merged together.
Turns out this doesn't work either, because sometimes you need to define a type twice, which causes a collision when merging.
For instance, type User is defined (to the outside world) in schema.graphql without field "password" but is also auto generated in prisma.graphql with password.
img2695
So the basic problem here is:
We are building a public layer (schema.graphql) that needs to import autogenerated types from prisma.graphql. But not all generated types, because some (like User) are already custom defined in schema.graphql.

@cfnelson
Copy link
Contributor

@liuuu You may be running into issues if your mixing yarn & npm together and you didn't clear your node_modules/pkg-lock.json. From the error message you have the issue you might be running into is dependent on what types you have in your graphql files. Would need a minimal reproduction to be able to understand the issue your having better.

@cfnelson
Copy link
Contributor

@beebase If I understand correctly, what you have described is the ability too merge the same two types together (which have been defined in two files). Specifically what you are hoping to achieve is to merge the field definitions together or in your case have some field definitions omitted in your final type definition.

Currently this isn't supported by this package as it comes with various complications. We have a discussion over on issue #113 which is where I think we should continue this discussion. And would be interested to hear your input on the matter.

Also to clarify in your schema.graphql file contains only your type definitions?

@beebase
Copy link

beebase commented Jan 24, 2018

Thanks, I'll have a look at #113.
And yes, schema.graphql holds the type defs. Eventually this file will be divided into user.grapgql, post.graphql, comment.graphql etc...

@davidjohnbell
Copy link

Hello, I am trying to implement your library. When I downgraded graphql to 0.11.7 I get an error when I try to use subscriptions. I can perform queries and get the proper data, but subscriptions seem to throw an error inside the graphiql playground.

// ./graphql/resolvers/myResolvers.js
module.exports = {
  Query: {
    hello: () => `Hello`,
    rachelsQuery: () => `hello from rachels query`,
  },
  Counter: {
    countStr: counter => `Current count: ${counter.count}`,
  },
  Subscription: {
    counter: {
      subscribe: (parent, args, { pubsub }) => {
        const channel = Math.random().toString(36).substring(2, 15) // random channel name
        let count = 0
        setInterval(() => pubsub.publish(channel, { counter: { count: count++ } }), 2000)
        return pubsub.asyncIterator(channel)
      },
    }
  }
}
// ./graphql/types/types.graphql
type Query {
    hello: String!
    rachelsQuery: String!
}
type Counter {
    count: Int!
    countStr: String
}
type Subscription {
    counter: Counter!
}

// graphiql web playground error
{
  "data": null,
  "error": [
    {
      "message": "Cannot use GraphQLSchema \"[object Object]\" from another module or realm.\n\nEnsure that there is only one instance of \"graphql\" in the node_modules\ndirectory. If different versions of \"graphql\" are the dependencies of other\nrelied on modules, use \"resolutions\" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate \"graphql\" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results."
    }
  ]
}

capture

@cfnelson
Copy link
Contributor

@davidjohnbell It sounds like you might have two different versions of graphql installed? At least from that error. Might be another package has graphql as a direct dependency?

However potentially another quick solution to test would be to swap out the graphql 0.11.7 with the specific github npm branch which is not yet published. yarn add graphql@git://github.com/graphql/graphql-js.git#npm.

@davidjohnbell
Copy link

davidjohnbell commented Jan 29, 2018

@cfnelson thank you for your speedy reply. I tried the pulling from their git previously and got the same error as above. Could there be some sort of error specific using graphql-yoga? This was my package and if I deleted the node modules and installed using npm install I still get the error.

{
    //...Omitted for brevity

    "dependencies": {
        "express": "^4.16.2",
        "graphql": "0.11.7", //or github
        "graphql-yoga": "^1.2.1"
        "merge-graphql-schema": //Latest version num 
    },

    //...Omitted for brevity
}

EDIT:
I tried ununstalling everything until I was back to just graphql-yoga and I still got an error. I know this shouldn't be the case because Ive tested the project in this state before and had it work. So I fresh installed graphql-yoga and that seemed to fix my base case error which might do the trick. Thanks

@cfnelson
Copy link
Contributor

@davidjohnbell I suspect the issue is due to graphql-yoga having graphql: ^0.12.0 as a dependency - see here. Hopefully all this is resolved once 0.12.4 is released.

@arvi
Copy link

arvi commented Jan 31, 2018

Right, I had to change ^0.12.3 to 0.11.7 for it to work. 😄 thanks to all.

@email2vimalraj
Copy link

This works fine with the recent release candidate version of graphql - "graphql": "^0.13.0-rc.1".

@bvitale
Copy link

bvitale commented Jan 31, 2018

Can also confirm fixed with RC1

@negezor
Copy link

negezor commented Feb 15, 2018

GraphQL v0.13.0 released

The getDescription function was returned.

@goddtriffin
Copy link

Non-broken GraphQL v0.13.0 link: https://github.com/graphql/graphql-js/releases/tag/v0.13.0

PR: graphql/graphql-js#1165

This issue can be closed.

@RichardLitt
Copy link
Contributor

@magnusfrater Oughtn't we to update our dep, first?

@cfnelson
Copy link
Contributor

v1.5.0 has just been released and resolves this issue if you have installed graphql v0.13.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎙️question Further information is requested
Projects
None yet
Development

No branches or pull requests