Question about GraphQL API introspect

94 views
Skip to first unread message

Tiger Yuhao Huang

unread,
Apr 28, 2019, 6:30:03 AM4/28/19
to Artsy API Developers
First of all, thank you very much for your generosity to provide a public GraphQL API, it allows me to build projects about art and artists!

My problem is

I am trying to download schema.json with Apollo introspect, I had the following error, do you guys know any workaround?

apollo schema:download --endpoint=https://metaphysics-production.artsy.net/ schema.json

Error: Name "__id" must not begin with "__", which is reserved by GraphQL introspection.
Name "__id" must not begin with "__", which is reserved by GraphQL introspection.
Name "__id" must not begin with "__", which is reserved by GraphQL introspection.
Name "__id" must not begin with "__", which is reserved by GraphQL introspection.
Name "__id" must not begin with "__", which is reserved by GraphQL introspection.
Name "__id" must not begin with "__", which is reserved by GraphQL introspection.
Name "__id" must not begin with "__", which is reserved by GraphQL introspection.
Name "__id" must not begin with "__", which is reserved by GraphQL introspection.
Name "__id" must not begin with "__", which is reserved by GraphQL introspection.

Tiger Yuhao Huang

unread,
May 1, 2019, 4:38:48 PM5/1/19
to Artsy API Developers

I dig a little bit more on this. 


In the Spec in the Schema section, quote


All types and directives defined within a schema must not have a name which begins with "__" (two underscores), as this is used exclusively by GraphQL’s introspection system



In terms of code, the lines are here

export function isValidNameError(
  name: string,
  node?: ASTNode | void,
): GraphQLError | void {
  invariant(typeof name === 'string', 'Expected string');
  if (name.length > 1 && name[0] === '_' && name[1] === '_') {
    return new GraphQLError(
      `Name "${name}" must not begin with "__", which is reserved by ` +
        'GraphQL introspection.',
      node,
    );

The workaround I use now is to temporally comment out the above few lines of codes...

 

Screenshot 2019-05-01 at 21.22.11.png

ro...@artsymail.com

unread,
May 2, 2019, 10:37:03 AM5/2/19
to Artsy API Developers
Thanks for your interest in our GraphQL API!


For historical reasons, we have a field named __id, which as you've discovered does not conform to GraphQL's recommended naming conventions.


In our own tooling we use https://github.com/ds300/patch-package to apply a patch at package installation time, which does pretty much the same thing you've done as well.


For example, see this patch in our web client https://github.com/artsy/force/blob/master/patches/graphql%2B0.13.2.patch

-- 
[A.] Roop
Engineer @ Artsy

ro...@artsymail.com

unread,
May 3, 2019, 9:37:09 AM5/3/19
to Artsy API Developers
Please note, however, that the Public API Terms of Use (https://developers.artsy.net/v2/terms) do not grant rights to the usage of the Artsy GraphQL API in your applications.

Thanks!

-- 
[A.] Roop
Engineer @ Artsy

Tiger Yuhao Huang

unread,
May 3, 2019, 3:33:04 PM5/3/19
to Artsy API Developers
Thank you very much for the information. 
Reply all
Reply to author
Forward
0 new messages