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

How does type extension work? #483

Closed
tonyxiao opened this issue Sep 9, 2016 · 9 comments
Closed

How does type extension work? #483

tonyxiao opened this issue Sep 9, 2016 · 9 comments

Comments

@tonyxiao
Copy link

tonyxiao commented Sep 9, 2016

I see some commits that adds the following syntax

type Hello {
  world: String
}
extend type Hello {
  world2: String
}

However I can't find any docs around just what it is and how to use it. And if I actually try to use it in code I get the following message.

Error: Client Schema cannot be used for execution.

Can someone clarify how to use type extension in GraphQL?

@robzhu
Copy link
Contributor

robzhu commented Nov 8, 2016

Hey @tonyxiao, can you please post the code you're running to execute type extension?

@tonyxiao
Copy link
Author

tonyxiao commented Nov 8, 2016

Hmm I was using it together with ApolloStack. apollostack.com Maybe they are using an older version of graphql js and that's why there's error?

@stubailo
Copy link

stubailo commented Nov 8, 2016

Sounds like it should be an issue on graphql-tools? https://github.com/apollostack/graphql-tools

I'd close the one here.

@robzhu
Copy link
Contributor

robzhu commented Jan 11, 2017

Closing this since I haven't seen any movement on this for a while. @tonyxiao, please feel free to re-open if feel there's something specific and actionable we can do in this repo.

@robzhu robzhu closed this as completed Jan 11, 2017
@stubailo
Copy link

feel free to open an issue on graphql tools about documenting this.

@dyst5422
Copy link

I'm still seeing extend not work at all with graphql or express-graphql. Minimal failing example attached.

import { buildSchema, graphql } from 'graphql';

const schema = buildSchema(`
type QuerySubset {
  hello: String
}

type Queries {
  querySubset: QuerySubset
}

extend type Queries {
  hello: String
}

type Query {
  Queries: Queries
}

schema {
  query: Query
}
`)

const rootResolver = {
  Queries: {
    querySubset: {
      hello: () => 'hello world',
    },
    hello: () => 'hello world',
  }
};

// Works fine
graphql(schema, `{ Queries { querySubset { hello } } }`, rootResolver).then(response => {
  console.log(response);
})

// Errors out with 'Cannot query field "hello" on type "Queries".'
graphql(schema, `{ Queries { hello } }`, rootResolver).then(response => {
  console.log(response);
})

@krabbypattified
Copy link

Why is this closed? I would like to know how the extend keyword works and it's not documented.

@dyst5422
Copy link

dyst5422 commented Aug 2, 2017

@krabbypattified See the closed issue #892 and associated issue #922

@dandv
Copy link

dandv commented May 19, 2019

TL;DR - use graphql-tools for now.

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

6 participants