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

GraphQLEnumType doesn't work if value doesnt match the key #1997

Closed
stringbeans opened this issue Jun 27, 2019 · 4 comments
Closed

GraphQLEnumType doesn't work if value doesnt match the key #1997

stringbeans opened this issue Jun 27, 2019 · 4 comments
Labels

Comments

@stringbeans
Copy link

stringbeans commented Jun 27, 2019

Experiencing this in both 14.4.0 and 14.3.1 with apollo-server-express@2.6.2

I have a simple query:

const LanguageCode = new GraphQLEnumType({
  name: 'LanguageCode',
  values: {
    en: {
      value: 'english'
    },
    fr: {
      value: 'french'
    }
  }
})

export default {
  type: ListResultInterface(SchoolCompanyPromotionObject),
  args: {
    languageCode: {
      type: LanguageCode
    }
  },
  resolve
}

However, when I try to access this query...

query {
  myQuery(languageCode: en) {
    # ...fields
  }
}

I receive the following error: "Variable \"$_v1_languageCode\" got invalid value \"english\"; Expected type LanguageCode."

However, if I map the value to be the same as the key (en: {value: 'en'}) then the query works.

@stringbeans
Copy link
Author

stringbeans commented Jun 27, 2019

hmm... after digging into it a little bit I've noticed that this occurs only if i use mergeSchemas fn from graphql-tools to produce the schema to pass into apollo-server-express. if i use the schema directly then it works fine..

@stringbeans
Copy link
Author

i was able to fix this problem by reverting to graphql@0.13.0 and graphql-tools@2.22.0. seems as though its something with schema stitching but i had to revert both graphql and graphql-tool packages in order to properly fix the issue

@IvanGoncharov
Copy link
Member

@stringbeans It's the issue with graphql-tools and reported here: ardatan/graphql-tools#1033
Also fixed here: ardatan/graphql-tools#1075

@stringbeans
Copy link
Author

@IvanGoncharov thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants