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

enhance(stitch): introduce SubschemaSetConfig #1994

Merged
merged 1 commit into from Sep 4, 2020
Merged

Conversation

yaacovCR
Copy link
Collaborator

@yaacovCR yaacovCR commented Sep 4, 2020

to improve ergonomics of sharing endpoint details between subschemas

to improve ergonomics of sharing endpoint details between subschemas
@theguild-bot
Copy link
Collaborator

theguild-bot commented Sep 4, 2020

The latest changes of this PR are available as alpha in npm: 6.2.1-alpha-6d92adab.0

Quickly update your package.json by running:

npx match-version @graphql-tools 6.2.1-alpha-6d92adab.0

@yaacovCR yaacovCR merged commit 6d92ada into master Sep 4, 2020
@yaacovCR yaacovCR deleted the subschema-set-config branch September 4, 2020 04:24
@gmac
Copy link
Contributor

gmac commented Sep 5, 2020

I see. So this structure is what computed field isolations would/should produce? Looks good, I like that there’s still just a single subschema.

@yaacovCR
Copy link
Collaborator Author

yaacovCR commented Sep 5, 2020

Yes, but now we don't even need a new type you can just return an array of SubschemaConfig objects.

#2001

@yaacovCR
Copy link
Collaborator Author

yaacovCR commented Sep 5, 2020

To share an endpoint and pool batching, just use identical object with endpoint details in the endpoint property of the members of the array instead of putting the endpoint details within the parent SubschemaConfig object.

May make sense in v7 to make the endpoint details always be required to be within the endpoint property instead of parent object just for consistency, but I think small potatoes.

@yaacovCR yaacovCR mentioned this pull request Sep 5, 2020
Merged
@gmac
Copy link
Contributor

gmac commented Sep 5, 2020

I’m not familiar with how endpoint works yet... is it a new expectation that executor goes into endpoint to facilitate batching, and one needs to update their subschema config with this property to enable batching?

@yaacovCR
Copy link
Collaborator Author

yaacovCR commented Sep 6, 2020

Batching will work if executor in SubschemaConfig, but to enable batching across SubschemaConfigs, it must be a property of an endpoint object with the same object then used in multiple SubschemaConfig objects. See

const endpoint: Endpoint = {
batch: true,
executor: ((params: ExecutionParams): ExecutionResult => {
executions++;
return execute(innerSchemaA, params.document, undefined, params.context, params.variables) as ExecutionResult;
}) as SyncExecutor
};
const innerSubschemaConfigA: Array<SubschemaConfig> = [{
schema: innerSchemaA,
transforms: [new FilterObjectFields((typeName, fieldName) => typeName !== 'Object' || fieldName !== 'field2')],
merge: {
Object: {
fieldName: 'objectA',
args: () => ({}),
},
},
endpoint,
}, {
schema: innerSchemaA,
transforms: [new FilterObjectFields((typeName, fieldName) => typeName !== 'Object' || fieldName !== 'field1')],
merge: {
Object: {
fieldName: 'objectA',
args: () => ({}),
},
},
endpoint,
}];

@gmac
Copy link
Contributor

gmac commented Sep 6, 2020 via email

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

Successfully merging this pull request may close these issues.

None yet

4 participants