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 to specify an id when no block is defined? #31

Open
pheyvaer opened this issue Aug 7, 2019 · 6 comments
Open

How to specify an id when no block is defined? #31

pheyvaer opened this issue Aug 7, 2019 · 6 comments
Labels
enhancement New feature or request

Comments

@pheyvaer
Copy link
Contributor

pheyvaer commented Aug 7, 2019

Assume you have the following query

{
  name
}

how do you select only the entities with id http://example.com/john?
When setting a block-scoped id there is like a "parent" where you can set the id (hero in the example of the link), but what do you need to do if you don't have that?

@pheyvaer pheyvaer changed the title How to get an id when no block is defined? How to specify an id when no block is defined? Aug 7, 2019
@rubensworks
Copy link
Owner

Something like this should work:

{
  id(_:'http://example.com/john')
  name
}

If it doesn't, then that should definitely become a feature :-)

@rubensworks rubensworks added the question Further information is requested label Aug 7, 2019
@pheyvaer
Copy link
Contributor Author

If I try that then I get GraphQLError: Syntax Error: Unexpected single quote character ('), did you mean to use a double quote (")?.

@rubensworks
Copy link
Owner

And does the double-quoted version work?

@pheyvaer
Copy link
Contributor Author

In that case, no error is thrown, but no results are returned.

@rubensworks rubensworks added bug Something isn't working and removed question Further information is requested labels Aug 11, 2019
@julianrojas87
Copy link

I tried something this scenario but instead of passing the id parameter on the query, I defined it in the @context and it worked fine:

{
   "@context": { "param": "http://example.org/john" }
}
----------------------------------------------------------------------
{
   id(_:param)
   name
}

@rubensworks
Copy link
Owner

Right, I forgot about that even. This makes param a GraphQL enum, which are always seen as URIs. Thanks for sharing @julianrojas87.

In any case, the id field will always point to a URI, so it should be possible to use a string value as an IRI instead of a literal. This is in fact not a bug, but a not-yet-implemented feature.

@rubensworks rubensworks added enhancement New feature or request and removed bug Something isn't working labels Sep 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants